use strict;
As the symbolic reference solution looked like a good solution when I
started, given the time saved by not having to go through all those report
scripts doing more then just prefix all variables with a dollar sign (and
keep the variables readable), I learned over time that use
strict;
was not a bad idea.
So I started to use lexicals, and convert the data structure from
$e010110
to $e[1]{110}
, something some of you,
if not most of you, would have thought of when faced with the problem in
the beginning.
From the programmers eye, this is no problem, but more simple users have less problems recognizing $e010240 as being the surname of the person is much easier than recognizing $e[1]{240}, but - since most of my user base didn't change to formats anyway, I decided that to be a minor problem.
Now the initialization becomes something like:
while (<>) { s/\s*$//; push @elp, $_; m/^99/ or next; # Convert the expanded LP-list to elements known in the format(s) foreach my $lp (@elp) { my ($cat, $type, $data) = split m/\|/, $lp, 3; $e[$cat]{$type} = $data; } # format this entity write; @e = (); }
... much cleaner and loosing the reset
, also less error-prone.
The format script would become something like:
format TOP = Gemeente @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Blad: @>>>>>> $s_gem, $% Leerlingen Datum: @<<<<<<<<< @<<<< $D_sys, $T_sys =============================================================================== Achternaam Voornaam + initialen Geb dat Gesl Adres Postcode + Plaats SrtOnd School Klas ------------------------------------------------------------------------------- . format A01 = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>> $e[1]{241}, $e[1]{214}, "$e[1]{311} $e[1]{411}" $line1 @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $e[1]{1100}, $e[1]{1025} ~ @<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<< $e[1]{2021},$e[1]{2012}, $e[1]{2040} .