Path: utzoo!attcan!uunet!nems!ark1!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!usc!apple!sun-barr!ccut!ascgw!fgw!flab!ayumi!kumon From: kumon@asami.stars.flab.Fujitsu.co.jp (Kouichi Kumon) Newsgroups: comp.lang.perl Subject: Regexp bug in print context? Message-ID: Date: 13 Apr 90 04:08:49 GMT Sender: news@ayumi.stars.flab.fujitsu.co.jp (News) Reply-To: kumon@flab.fujitsu.co.jp Organization: Fujitsu Laboratories Ltd., ... Lines: 32 I was amazed at the behavior of regular expression searches in print contexts. The following program calls subroutine &sub twice, and the subroutine searches the same regexp from the same string. But the actions are different. The first subroutine call succeeds, but the second doesn't. When regexp /(0)/ in the fifth line is changed to /(1)/ or /0/ , it works. Isn't it a bug? -------------------------- print &sub."\n"; print &sub,"\n"; sub sub { $c = "xx0x1x"; if ($c =~ /(0)/) { # Why this regexp doesn't match the pattern? "Ok found"; } else { die " not found\n"; } } -------------------------- RUNNING ENVIRONMENT Perl patchlevel 18 under sun4/110 sunos-4.0.1, use bison -y, compiled with cc -O2. -- Artificial inteligence lab, Fujitsu labs. kumon@flab.fujitsu.co.jp