> | for(my $i=0; $i<22; $i++){<WORKFLOW>};
> |   $_=<WORKFLOW>;
> |   my $line=$_;
> |   my $nextline=$line++;
> | if ((substr($line, 42, 7) eq "Running") ||
> | (substr($nextline, 42, 7)eq
> | "Running"))
> >
> > while (<WORKFLOW>) {
> >    # Skip lines upto line 23
> >    next if $.<22;
> > 
> >    # Process for line 23 & 24
> >    if (substr ($line, 42, 7) eq "Running") {
> >        ...
> >    }
> > }
> > 
> > # Make sure we definately got enough lines
> > unless ($.=24) { die "We were sold short!" }
>
> If I use you command it will only check line 23
> and not 24, right?

In the original code you had ||, suggesting you didn't care
which line the match occured on since you undertook the
same action regardless.  I don't have enough information to
verify that my code will do EXACTLY what you want...

I missed out a test to terminate the loop for line 25,
which you definately don't want to look at.  Change the
loop to:

while (<WORKFLOW>) {
    # Skip lines upto line 23
    next if $.<22;

    # Process for line 23 & 24
    if (substr ($line, 42, 7) eq "Running") {
        ...
    }

    # Terminate loop once line 24 is processed
    last if $.==24;
}


This code is REALLY SQUEAKY CLEAN(TM), hence it should be
quite clear what it does (and is perhaps free from further
errors).  $. is the current line number of the file you're
working with - beyond that it should be extremely familiar
looking.

Incidentally, you MAY "use English;" to make $. into the
more readable variable of $INPUT_LINE_NUMBER.  Be warned,
this english module will slow down most scripts!  (Because
of forcing the $& variable to be created and updated when
regex's are run).  Besides, if you were writing scripts for
me I'd prefer the shorter version :)

Jonathan Paton

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to