in reply to Re^2: Optimal way to read in pipe delimited files
in thread Optimal way to read in pipe delimited files


Could someone please explain the significance of shift@a,[@a] in the above map? I tried removing this statement and it did not work. I really dont know what that statement is doing.
Also I did not understand why [@a] is to be used if my is not used.
thanks
narashima

Replies are listed 'Best First'.
Re^4: Optimal way to read in pipe delimited files
by duff (Parson) on Nov 09, 2005 at 22:51 UTC

    Because my gives you a new variable each time through the loop, you can use \@a and all it well because it's a different @a each time. When you don't use my within the loop, it's always the same variable. Thus @a = (1,2,3); $a = \@a; @a =(4,3,9); $b = \@a; will cause $a and $b to both reference the same memory location which will contain the values (4,3,9). [@a] makes a copy of @a and returns a reference to it, so you get a new chunk of memory each time.