On Sep 6, Paul Jasa said:

>How do I put something I am looking for, and find, with a reg expression
>INTO a variable?

You want to capture the specific part of the regex with ( and ), and then
set that equal to a variable.  There are two ways of doing that:

  if (/(pattern)/) {
    $x = $1;  # $1 is the first set of ()'s
  }

and

  ($x) = /(pattern)/;

So you probably want:

  if ($iplist =~ /((?:\d{1,3}\.){3}\d{1,3})/) {
    print "found $1\n";
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to