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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.