in reply to IP address!

Bad! Never look at $1 unless you do it conditionally on the regex match. If the match fails, you get the previous regex match's $1.

Replies are listed 'Best First'.
RE: RE: IP address!
by Adam (Vicar) on May 05, 2000 at 23:16 UTC
    Thats a really good point, something that is kind of frustrating because it makes the code more complex. Also, note that ifconfig is a linux thing, not an NT thing... so this thing is not portable.
    $_ = `/sbin/ifconfig $if`; (/inet addr:((\d{1,3}\.?){4})/m) ? ($ipaddr = $1) : (warn 'ifconfig failed');
    I seem to remember there being a get function that does this too, but I can't remember it at the moment.
      NT DOES have ipconfig, however..
RE: RE: IP address!
by au (Initiate) on Jul 20, 2000 at 22:24 UTC
    I think also local may be used.
    { local $1; $string =~ m/(something)/; $found = $1; }