Skip to content

Instantly share code, notes, and snippets.

@AndrewRussellHayes
Last active December 28, 2015 21:49
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/7567108 to your computer and use it in GitHub Desktop.
Save AndrewRussellHayes/7567108 to your computer and use it in GitHub Desktop.
this code will keep running until enter is pressed and then continue running.
while(){
runUntilEnterPressed();
enterWasPressed();
}
sub runUntilEnterPressed{
my $input;
my $select_object = IO::Select->new(); $select_object->add(\*STDIN);
my $sleep = .1;
until($input){
print doSomethingAwesome(); #thing to keep doing until enter is pressed
if ($select_object->can_read($sleep ||.5)){$input = <STDIN>}
}
undef $input
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment