in reply to Re^2: Matching next line in text file
in thread Matching next line in text file

I made $stn a hash ref because this isn't going to work:

$seg{$lname} = { 'header' => \@hdr, 'stations' => \%stn, };
You'll find that the header will always point to the same array. The same will be true for stations - all of them will be the same hash.

However, if you make the stn hash a hash ref, then this will work:

# time to save stn and headers: $seg{$lname} = { header => [ @hdr ], stations => $stn }; @hdr = () $stn = undef;
Note the square brackets around @hdr - this will create a new array.