Re: Several Perl Questions - Nov. 5, 2013

Discussion in 'Perl Misc' started by Jürgen Exner, Nov 12, 2013.

  1. Henry Law <> wrote:
    >On 12/11/13 10:10, E.D.G. wrote:
    >> now an ancient version of Fortran

    >
    >That explains (but IMO doesn't excuse) a lot about the code. First
    >thing I thought when I tried, and failed, to read it through is that it
    >looks like FORTRAN written in Perl: the lack of indentation; the GOTO
    >statements; and the labels used to implement loops. Like this fragment.
    >
    >> getdatalines:; # start and return point of loop to process another test file line - includes next 15 lines
    >> $num1 = $num + 1;
    >> if ($num1 > 1000){goto programerror};# at end of program
    >> $dataline[$num1] = $word;
    >> $charnum = -1;
    >> $word = "";
    >> $num = $num + 1;
    >> $numdatalines = $num;
    >> if (substr($tlin[$num], 0, 45) eq '***** END OF THE CONTROL SETTINGS SECTION ***'){goto processtestdata2};
    >> # the above line jumps about 8 lines down when the extract data lines routine ends
    >> nextchar:;# start of and return point to get settings values - includes next 8 lines
    >> $charnum = $charnum + 1;
    >> $char = substr($tlin[$num],$charnum,1);
    >> if ($char eq " " || $char eq "," || $char eq ""){goto getdatalines};
    >> # the above line jumps back to start of routine about 15 lines up
    >> $word = $word.$char;
    >> goto nextchar;# jump 6 lines up to test another character


    Oh my $DEITY !!!
    Are there really people writing code like this? This would have been bad
    code 30 years ago. It would have gotten a clear "Fail" in any of my
    classes 20 years ago. And it surely hasn't improved with age since.

    Recommendation: if this snippet is representative of the rest of the
    code then dump it and don't walk but run away as fast as you can. This
    code is worse than junk and long overdue for a complete rewrite from
    scratch.

    And no, there is no indentation missing in this snippet. Thanks to the
    horrible style all the lines actually do begin on the correct level. And
    that is a bad, bad indicator when all your code is left-aligned.

    jue
     
    Jürgen Exner, Nov 12, 2013
    #1
    1. Advertising

  2. Jürgen Exner

    John Bokma Guest

    John Bokma, Nov 13, 2013
    #2
    1. Advertising

  3. Henry Law <> wrote:
    >On 12/11/13 21:23, Jürgen Exner wrote:
    >> there is no indentation missing in this snippet

    >
    >Indeed, that's true; what I snipped wasn't representative. Try this:


    [snip-snap]

    Please don't! Reading those code fragments is cruel and unusual
    punishment.
    Even worse than being forced to watch all episodes of Gilligan's Island
    or Golden Girls.

    jue
     
    Jürgen Exner, Nov 14, 2013
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charlton Wilbur

    Re: Several Perl Questions - Nov. 5, 2013

    Charlton Wilbur, Nov 5, 2013, in forum: Perl Misc
    Replies:
    3
    Views:
    137
    Charlton Wilbur
    Nov 11, 2013
  2. John Black

    Re: Several Perl Questions - Nov. 5, 2013

    John Black, Nov 5, 2013, in forum: Perl Misc
    Replies:
    0
    Views:
    129
    John Black
    Nov 5, 2013
  3. Peter J. Holzer

    Re: Several Perl Questions - Nov. 5, 2013

    Peter J. Holzer, Nov 5, 2013, in forum: Perl Misc
    Replies:
    3
    Views:
    145
    Peter J. Holzer
    Nov 7, 2013
  4. Peter J. Holzer

    Re: Several Perl Questions - Nov. 5, 2013

    Peter J. Holzer, Nov 5, 2013, in forum: Perl Misc
    Replies:
    0
    Views:
    122
    Peter J. Holzer
    Nov 5, 2013
  5. Tim McDaniel

    Re: Several Perl Questions - Nov. 5, 2013

    Tim McDaniel, Nov 5, 2013, in forum: Perl Misc
    Replies:
    0
    Views:
    163
    Tim McDaniel
    Nov 5, 2013
Loading...

Share This Page