in reply to Re: otherwise condition
in thread otherwise condition

Dear respondees,
bobn's code is exactly what I was looking for thankyou.
Sorry to confuse people with the code in my while loop, it does exactly what I want it to do although it has correctly been pointed out that it is messy. In response to a specific query, the chop is used to get rid of a semicolon that is always at the end of the pattern.
The else part is unfaulty code but does not do what I want it to do.
Many thanks.

Replies are listed 'Best First'.
Re3: otherwise condition
by dragonchild (Archbishop) on Aug 25, 2003 at 14:21 UTC
    the chop is used to get rid of a semicolon that is always at the end of the pattern.

    I would recommend either commenting that it is removing a semi-colon or using a pattern match to get rid of it, along the lines of $line =~ s/;$//;. Unless this is a script which has to execute in a specific amount of time, self-commenting code is much better than fast code.

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      Or just drop the chop altogether and use
      $chain=substr($line,length($line)-2,1);
      instead of
      $chain=substr($line,length($line)-1,1);