> >> while (<INPUTDATA>) {
> >>     chomp;
> >>     s/^\s+//;
> >>     next if (m/^$/ || (1 .. /^NPROC/));
> >
> > what does the range thing do?
> > wouldn't just ... || /^NPROC/   be enough?
> 
> ok. opposite sense:   || ! /^NPROC/

So that would be:

 next if (m/^$/ || ! /^NPROC/);

Which means skip processing the line if it's an empty line or if the
line doesn't begin with NPROC...

What (1 .. /^NPROC/) does is it returns true until it matches /^NPROC/
and then returns false every time it's called after that.

[snip from perldoc perlop]
    In scalar context, ".." returns a boolean value. The operator is
    bistable, like a flip-flop, and emulates the line-range (comma)
operator
    of sed, awk, and various editors. Each ".." operator maintains its
own
    boolean state. It is false as long as its left operand is false.
Once
    the left operand is true, the range operator stays true until the
right
    operand is true, *AFTER* which the range operator becomes false
again.
    It doesn't become false till the next time the range operator is
    evaluated. It can test the right operand and become false on the
same
    evaluation it became true (as in awk), but it still returns true
once.
    If you don't want it to test the right operand till the next
evaluation,
    as in sed, just use three dots ("...") instead of two. In all other
    regards, "..." behaves just like ".." does.
 ...
    If either operand of scalar ".." is a constant
    expression, that operand is implicitly compared to the "$."
variable,
    the current line number. Examples:

    As a scalar operator:

        if (101 .. 200) { print; }  # print 2nd hundred lines
        next line if (1 .. /^$/);   # skip header lines
        s/^/> / if (/^$/ .. eof()); # quote body
[/snip]

Cheers,

 -dave



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

Reply via email to