Created
November 20, 2013 17:27
-
-
Save AndrewRussellHayes/7567302 to your computer and use it in GitHub Desktop.
flips single file switch, used for development purposes typically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub flipSwitch{ | |
my $file = shift; | |
my $fileHandle; | |
my $value; | |
open($fileHandle,'<',$file) || warn "cant open switch file $!"; | |
$value = <$fileHandle>; | |
close($fileHandle); | |
chomp($value); | |
if($value){$value = 0;} | |
else {$value = 1;} | |
open($fileHandle,'>',$file) || warn "cant open switch file $!"; | |
print $fileHandle "$value"; | |
close($fileHandle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment