in reply to Reprinting Text With Changing Fields

As others already pointed out, your original code was not handling an array ref properly (and didn't need it in the first place). But if your question is how to give different node sets to the loop, you could try:

my @node_number = @ARGV; for my $nn ( @node_number ) { print <<EOF; node = $nn ccu = 5 ccu2 = 9 tacaf = y enable = y sync = 8 EOF }
Then you can invoke your program with:
% perl my_program.pl 4 13 1 22 14

the lowliest monk

Replies are listed 'Best First'.
Re^2: Reprinting Text With Changing Fields
by awohld (Hermit) on Apr 20, 2005 at 18:46 UTC
    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
      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