Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
Created November 20, 2013 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewRussellHayes/7567302 to your computer and use it in GitHub Desktop.
Save AndrewRussellHayes/7567302 to your computer and use it in GitHub Desktop.
flips single file switch, used for development purposes typically
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