in reply to Re: Reprinting Text With Changing Fields
in thread Reprinting Text With Changing Fields

Okay I got it to work with the @ARGS, so it works with:

%perl my_program.pl 4 13 1 22 14

How can I also get it to work with a text file that has the arguments listed in it?

I'd like to get it to also work with:

%perl my_program.pl < textfile.txt

Replies are listed 'Best First'.
Re^3: Reprinting Text With Changing Fields
by tlm (Prior) on Apr 20, 2005 at 18:56 UTC
    my @node_number = do { local $/; split ' ', <> }; # etc.

    the lowliest monk

      So I need it to take @ARGS or the "<" redirect. If there aren't @ARGS or a "<" I need it to print a message saying "use args or <". I think I'm on the right track but it hangs if I don't "<" any text file in. I can't really get it to work.

      So I have:

      if(@ARGV) { my @node_numbers= @ARGV} else { my @node_numbers = do { local $/; split ' ', <> };} if (!@node_numbers) { print <<"EOF"; ##################################### # # use args or < a text file # ##################################### EOF die; } # Do rest of code after here using @node_numbers