in reply to $1 don't reset (non loop)

Why doesn't $1 reset when the regexp doesn't match anything?

It's a feature, not a bug :-)

Actually there are times when it comes in handy, if I'm doing stuff where I need it to be redefined I usually use an if {} elsif{} else{} loop. That way it only goes into the {} if the if (or elsif) matches. If you don't want to use an elsif (because you are checking a few things) just use multiple if statements.

Replies are listed 'Best First'.
Re: Re: $1 don't reset (non loop)
by jockel (Beadle) on Feb 17, 2004 at 14:01 UTC
    Well... this time I think it's a bug =)..
    It would've been great if you could define this so
    called "feature" with a special $ variable.

    Anyway .. now when I know about this "feature" and won't make the mistake again =)
    /jocke