Dear Monks
I have little program which gives me error:
syntax error at pipe.pl line 25, near "<$result->{fh"
Here is code:
#!/usr/bin/perl use strict; use warnings; my ( $program, $arguments ) = ( "netstat", "-n" ); my @results; for ( my $n = 0; $n < 5; $n++ ){ print "Opening FH for $n..."; my $pid = open my $fh, "-|", "$program $arguments" or die $!; push @results, { pid => $pid, fh => $fh }; print " Done!\n"; } foreach my $result (@results) { print "=" x 5, $result->{pid}, "=" x 5, "\n"; my $fh = $result->{fh}; while ( my $line = <$result->{fh}> ) { print $line; } close $result->{fh}; }
At this moment i change it to:
my $fh = $result->{fh}; while ( my $line = <$fh> ) {
but i have a question why perl doesn't like that (and what to do)?
Update: This is perl, v5.8.9 built for MSWin32-x86-multi-thread.
In reply to <> and $hash_ref->{key} construct by Gangabass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |