in reply to Re: make a hash globally accessible
in thread make a hash globally accessible

I do not like that eval. I would rather use a hash of subroutine references or a wrapper subroutine taking the segment value or a closure scheme.

That said, you're very close. Assigning the results of the ProcessSegmentxxx call to %seg000 would work -- if you actually returned the hash from the subroutine. Likewise, passing a reference to the hash would work -- if you actually used the reference in the subroutine to hold data.

The code to do that would be similar to:

sub ProcessSegment000 { my $dataline = shift; my $seg000 = shift; $seg000->{fileid} = substr($dataline,0,3); # et cetera
Note the dereferencing arrow.

Seriously though, I shudder to think at the kind of work you mihgt have to do to update all of those similar subs. That'll be the next thing to tackle, right?