hi deane --   
 
In a message dated 1/8/2007 3:11:24 P.M. Eastern Standard Time,  
[EMAIL PROTECTED] writes:
 
> Gurus, 
> 
> I've not seen this done, so I don't know if  it can be, but...
> Is there a way to get $1 from a pair of parens in a  regexp
> into a variable in one line? That is... 
>  
>   my $foo = 'http://10.20.30.40/gargle'; 
>    
>   $foo =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;  
>   my $fee = $1; 
>   
>    print "IP = \"$fee\"\n"; 
> 
> ...is there some way to get the  second and third lines into one line? 
> 
> Deane  Rothenmaier


C:[EMAIL PROTECTED]>perl -we "use strict;  my $foo =  
'http://10.20.30.40/gargle';
my ($ip) = $foo =~  /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;  print qq(IP = 
'$ip' \n);
IP =  '10.20.30.40'

C:[EMAIL PROTECTED]>perl -we "use strict;  my $foo =  
'http://10.20.30.40/gargle';
my ($oct1, $oct2, $oct3, $oct4) = $foo =~  /(\d{1,3}) \. (\d{1,3}) \. 
(\d{1,3}) \. (\d{1,3})/x;
print qq(IP = '$oct1 -  $oct2 - $oct3 - $oct4' \n);
IP = '10 - 20 - 30 - 40'

hth -- bill walters   
 

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to