What else and why

By that time, perl5 just hit the street, and I played with perl4 for some time, also building a perl interface to our (so far unsupported) database into perl4.

Reading the advantages of perl5 over perl4, the symbolic references hit me as extremely useful, because conversion would be easy as pie. The format part would become something like:

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<< @<<<
$e180010,                           $e180020,                 $e180030,$e180040
    @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $e180152,				     $e180212
~   @<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<
    $e180142,$e180263,                                          $e180270
.
format STDOUT_TOP =
Gemeente @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<             Blad: @>>>>>>
	 $s_gem,							$%
Leerlingen                                              Datum: @<<<<<<<<< @<<<<
							       $D_sys,   $T_sys
===============================================================================
Achternaam                          Voornaam + initialen           Geb dat Gesl
    Adres                                    Postcode + Plaats
    SrtOnd School                                              Klas
-------------------------------------------------------------------------------
.

which makes it already quite a lot easier to see what the user expects as output, and all the variables are the same, except for that funny leading dollarsign in front.
The initialization part would become real easy (shortened):

    while (<>) {
        chomp;
        push @elp, $_;
        m/^99/ || next;

        # Convert the expanded LP-list to elements known in the format(s)
        foreach $lp (@elp) {
            ($cat, $type, $data) = split m/\|/, $lp, 3;
            $data =~ s/\s+$//;
            $ect  = "$cat$type";
            $e    = "e$ect";
            $$e   = $data;
            }

        # format this entity
        write;

        reset "e";
        }

In fact, the first version of the perl equivalent of the 1350 line RPT script, were reduced to a mere 150 line of code!


Prev Next