Hi, all

Suppose file test.pl is:

my @ins = @ARGV;
foreach(@ins) {
       open IN, $_;
       while(<IN>) {
               chomp;
               print "@ins\n";
       }
       close IN;
}

and file case is:

a
b
c

When I run it in shell, using:
$ perl test.pl case

I thought it would be print:

case
case
case

but, actually it print:

a
b
c

As I wish, the print statement would print each element in array @ins. But
actually, it print every line in the input file. After the foreach loop, the
array @ins will be change to an array with an undefined value.

So, anyone could tell me, why and when the value of array @ins was
changed?Testing under perl 5.8 and perl 5.12.

-- 
*Odin Liu
*
RD Engineer
work mail: liuyid...@baidu.com
blog: http://blog.odichy.org/
profile: https://www.google.com/profiles/odinushuaia

Reply via email to