in reply to Re: How to accept ARG from PIPE or STDIN?
in thread How to accept ARG from PIPE or STDIN?
If you wanted to do:
dosomething.pl myfile.txtYou need to get the filename from the first element in @ARGV, the arguments array. You may also want to check out Multiple STDIN sources.
No. <> treats as a list of file names, and opens each of them in turn. <> only reads from STDIN if @ARGV is empty. In other words,
while (<>) { # do something with $_ }
works for all of the following:
cat myfile.txt | dosomething.pl dosomething.pl < myfile.txt dosomething.pl myfile.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to accept ARG from PIPE or STDIN?
by monkfan (Curate) on Mar 17, 2005 at 03:16 UTC | |
by ikegami (Patriarch) on Mar 17, 2005 at 04:34 UTC |