syphilis has asked for the wisdom of the Perl Monks concerning the following question:
On Cygwin and Linux, as expected, that prints out the first 7 lines of itself (ie the first 7 lines of $0).use warnings; use strict; use IO::Select; open(RD, '<', $0) or die "Can't open RD: $!"; my $s = IO::Select->new(); $s->add(\*RD); my @r = $s->can_read(); my $cum; if(@r) { # Assign the first 7 lines of this # file to $cum (1 byte at a time), # and print out $cum do { my $byte; sysread $r[0], $byte, 1; $cum .= $byte; } until $cum =~ /new\(\);/; print "\n\$cum:\n\n$cum\n"; } else { print "\@r contains no elements\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [Win32] IO::Select's can_read method
by Corion (Patriarch) on Dec 09, 2011 at 09:27 UTC | |
by syphilis (Archbishop) on Dec 09, 2011 at 09:42 UTC | |
by BrowserUk (Patriarch) on Dec 09, 2011 at 10:39 UTC | |
by Corion (Patriarch) on Dec 09, 2011 at 11:01 UTC | |
by patcat88 (Deacon) on Dec 09, 2011 at 17:26 UTC | |
| |
by BrowserUk (Patriarch) on Dec 09, 2011 at 11:11 UTC |