in reply to Re^2: Code optomization
in thread Code optomization

As you say, that probably happens when $3 isn't defined. Adding something like:
defined || last;
at the top of that for block would probably do the trick.

Replies are listed 'Best First'.
Re^4: Code optimization
by Roy Johnson (Monsignor) on Jul 08, 2004 at 21:31 UTC
    or make the "loop" for (grep defined, $3)

    We're not really tightening our belts, it just feels that way because we're getting fatter.
Re^4: Code optomization
by sock (Monk) on Jul 08, 2004 at 21:30 UTC
    I'm sorry, I don't understand. Can you explain a bit more? ----
    Guns don't kill people, ninjas do.
      The problem is that you're trying to do a pattern match against an undefined variable (if the regex doesn't match, or doesn't match enough, $3 will be undefined). My solution drops out of the "loop" immediately in this case, so it never tries to do the pattern match. Roy Johnson's solution avoids entering the loop at all if $3 is undefined.