in reply to Re^4: awk like question in perl
in thread awk like question in perl
Could also be written like this:
while ( my $line = <DATA> ) { my ( $second, $sixth ) = ( split //, $line )[1,5]; print $second, $sixth, "\n"; }
The unary + sign is used to signal to Perl that you mean print( (split)[1,5], "\n" ); and not print(split[1,5]),"\n"; (which doesn't make sense, but is confusing to Perl nevertheless.
For a description of split, see split. For a description of using slices, see perldata. For a description of what $/ is, see perlvar. And for an explanation of the "do something while condition" syntax, see perlsyn.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: awk like question in perl
by drock (Beadle) on Aug 12, 2004 at 21:12 UTC | |
by davido (Cardinal) on Aug 12, 2004 at 21:31 UTC |