Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Getting an IP out of a string

by raflach (Pilgrim)
on Aug 16, 2000 at 21:40 UTC ( [id://28156]=note: print w/replies, xml ) Need Help??


in reply to Getting an IP out of a string

m/(regex to match IP)/; print $1;
surround the regex to match the IP with parens, and then use the $1 variable to grab what was matched

Replies are listed 'Best First'.
RE: Re: Getting an IP out of a string
by merlyn (Sage) on Aug 16, 2000 at 22:14 UTC
    Danger will robinson!

    Never use $1 unless it's in the context of a conditional based on the success of the match. Otherwise, you get the previous success $1, and that's gonna bring you to tears while you're trying to debug it.

    -- Randal L. Schwartz, Perl hacker

      always the wise one.. :) ++merlyn
      Most people will tell you to learn from your mistakes, but I always think it's 100% better if you can learn from someone else's mistakes. This is actually one of the great reasons I visit Perlmonks -- the cooperative learning can't be beat!
      p.s. no offense intended to raflach: I might have made the same mistake.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://28156]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-03-28 22:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found