in reply to Re: Opening an array of file names
in thread Opening an array of file names

Thanks for the input. The line:

$newPrices{ $key } = \@line_array;

is what I had originally, but my understanding is that is a reference to the array, and since the array changes when the next line is read, it made all the values in my hash the same, the last line of the last file. I understand that using  $newPrices{ $key } = [@line_array] creates a copy of the array. It is quite possible that I am mistaken since this is the first time I have really sat down with Perl.

Replies are listed 'Best First'.
Re^3: Opening an array of file names
by jwkrahn (Abbot) on Apr 04, 2012 at 03:36 UTC

    my ( $key, @line_array ) on the previous line creates a new variable each time through the loop so it is safe to use a reference to this variable.    If the variable was in a larger scope then what you describe would be a problem.