The program: -- #use strict; use warnings; my $field = shift @ARGV; my $regex = '(\w+)\s*' x $field;
while (<STDIN>) {
if (/$regex/) {
print "$$field\n"; # refers to a match variable
}
}
--
Example Usage:
--
$ echo 'Strange New World!' | ./this_program 3
$ World
--
How could I do this with 'use strict' turned on?
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/
