in reply to Passing parameters to Perl Script
# your above script will work with this invocation: perlscript one two
Alternatively Use the -n switch to perl itself, which causes your code to run in a loop with $_ set to a line of input every iteration (see perlrun for more details):
#!/usr/bin/perl -n use strict; use warnings; my @words = split; # "split /\s+/, $_", more or less print "passed $_\n" for @words;
Update: Added missing my keyword, thanks K_M_McMahon.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Passing parameters to Perl Script
by holli (Abbot) on Feb 18, 2005 at 09:13 UTC | |
by blazar (Canon) on Feb 18, 2005 at 09:34 UTC |