Created
February 14, 2012 16:19
-
-
Save larsen/1827859 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| use strict; | |
| use warnings; | |
| use feature qw/ say /; | |
| my $timeout = 10; # seconds | |
| my $maxlines = 10; | |
| eval { | |
| local $SIG{ ALRM } = sub { | |
| say "Reading..."; | |
| my $counter = 0; | |
| while ( $counter < $maxlines ) { | |
| my $line = <>; | |
| print "$counter: $line"; | |
| $counter++; | |
| } | |
| alarm $timeout; | |
| }; | |
| say "Starting..."; | |
| alarm $timeout; | |
| while ( 1 ) {} | |
| }; | |
| if ( $@ ) { | |
| die "$@"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment