in reply to command line pipe
To actually get the filenames from the piped input, do something like:
A better solution for your particular example, though, is Zaxo's advice above. Use the -n option, or use the magic while (<>) loop: both automatically use the members of @ARGV as filenames and open them in sequence for you, reducing the code you've written to a one-liner.chomp( my @filenames = <STDIN> ); for (@filenames) { ... # open, read, etc }
Alternately, look at xargs to do something like this:
.. which takes the name of each txt file (as given by ls) and passes it as a command-line argument (i.e, an element of @ARGV) to myscript.pl (plus or minus quoting/escaping issues)$ ls *.txt | xargs ./myscript.pl
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: command line pipe
by pengyou_ah (Initiate) on Jul 23, 2003 at 06:25 UTC |