Welcome Guest!
 chicago-pm
 Previous Message All Messages Next Message 
Re: /i resets $1 on failed matches?  Andy_-@wiwb.uscourts.gov
 Jul 12, 2004 15:51 PDT 

Thanks Andy, er, that's why I suggested:
 I pointed out that:
cat b.txt |
    perl -ne 'print "$1\n"
if /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;'

The question (lost, as always, amongst my ramblings) was why '/i' seems to
avoid the "$1 retains the value of the last successfull match so testing
it after a failed match gets you a defined (and old) value" gotcha of
perl.

a

Andy Bach, Sys. Mangler
Internet: andy_-@wiwb.uscourts.gov
VOICE: (608) 261-5738 FAX 264-5932

Beware of bugs in the above code; I have only proved it correct, not tried
it. -- Donald Knuth
	
 Previous Message All Messages Next Message 
  Check It Out!

  Topica Channels
 Best of Topica
 Art & Design
 Books, Movies & TV
 Developers
 Food & Drink
 Health & Fitness
 Internet
 Music
 News & Information
 Personal Finance
 Personal Technology
 Small Business
 Software
 Sports
 Travel & Leisure
 Women & Family

  Start Your Own List!
Email lists are great for debating issues or publishing your views.
Start a List Today!

© 2001 Topica Inc. TFMB
Concerned about privacy? Topica is TrustE certified.
See our Privacy Policy.