On Wed, Mar 26, 2008 at 11:08 AM, <[EMAIL PROTECTED]> wrote:
> How do I mod the code to function as is with two args (perlscr
> list1.txt list2.txt)
> or accept stdin as data_file when only one arg is given? (cat
> list1.txt | perlscr list2.txt)
First off, I must not fail to induct you into the honorable order of
the UUoc for that Useless Use of cat, which should of course become:
perlscr list2.txt <list1.txt
That done, I'd probably just fake up the argument list at the top of
the program, like this:
unshift @ARGV, "<&=STDIN" if @ARGV == 1;
That special string tells perl's open function to reuse the STDIN
filehandle instead of opening another file.
Cheers!
--Tom Phoenix
Stonehenge Perl Training
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/