In a message dated 1/9/2007 11:52:30 A.M. Eastern Standard Time,  
[EMAIL PROTECTED] writes:
 
> However, you can't do:
> while ( my ($fee) = $foo =~  /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g ) {
> 
> as then the  assignment to $fee is the main connective and the match 
> restarts each  loop.


however, if evaluated in ``true'' (?) list context rather than the boolean  
context of 
a  while() { ... }  loop, the //g is allowed to run to  exhaustion.   e.g.:   
 
C:[EMAIL PROTECTED]>perl -we "use strict;  my $octet = qr(  \d{1,3} )x;
my $foo = 'http://10.2.3.4/gargle  _http://1.200.3.5/gargle_ 
(http://1.200.3.5/gargle)   _http://1.2.33.6/gargle'_ (http://1.2.33.6/gargle') 
;   print  
qq(\n);
print qq(Got one ip: $_ \n) for $foo =~  
/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g;        print qq(\n);
map { print qq(got an ip: $_ \n) } $foo =~  
/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/g;    print qq(\n);
for  my $ip ($foo =~ /($octet \. $octet \. $octet \. $octet)/xg) { print 
qq('nuther  ip: $ip \n) }"
 
Got one ip: 10.2.3.4
Got one ip: 1.200.3.5
Got one ip: 1.2.33.6
 
got an ip: 10.2.3.4
got an ip: 1.200.3.5
got an ip: 1.2.33.6
 
'nuther ip: 10.2.3.4
'nuther ip: 1.200.3.5
'nuther ip:  1.2.33.6


br -- bill   
 

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

Reply via email to