in reply to Getting the latest IP after dial-up

/inet\ addr:(\d+\.\d+\.\d+\.\d+)\s+.*$/; ... print MAIL $1;
I'd fail this in a code review. You've not assured a match on the regex, so the $1 there could be the previous $1, since the dollar vars are not updated on an unsuccessful match.

At the very minimum, put "or die" after the match.

-- Randal L. Schwartz, Perl hacker

  • Comment on •Don't use $1 without testing! (was Re: Getting the latest IP after dial-up)
  • Download Code

Replies are listed 'Best First'.
Re: •Don't use $1 without testing! (was Re: Getting the latest IP after dial-up)
by barrd (Canon) on Aug 25, 2002 at 16:50 UTC
    Thanks merlyn, the comments are valid and welcome. I'm rewriting the code with a filehandle to check and collect the old IP and only send a mail if different... I have much to learn.