On Tue, 2008-09-02 at 17:10 +0200, Paolo Gianrossi wrote: > On Tue, 2008-09-02 at 10:51 -0400, Mr. Shawn H. Corey wrote: > > > Sorry, it's Tuesday after a long weekend; brain is not fully in gear > > yet. Try: > > > > while( eval "\$text =~ s/$rexp/$replacement/$flags" ){ > > I tried this. Actually, I tried something slightly different: > > print "Enter rexp: "; > my $rexp=<STDIN>; > chomp($rexp); > while(eval "\$text =~ $rexp"){ > print length("$`\n"); > } > > which I assume should be exactly the same. > The problem here is that it prints 0 all the times it matches. > This is due, I believe, to the fact that $` (as well as $digit, $& and > the like) are dynamically bound to the eval block... > > I haven't found a way to "unlocal"-ize them... :(
Well, if you can't make it smaller, make it bigger. eval qq{ while( \$text =~ $re ){ print length( "\$`\n" ); } }; BTW backslash the variables you don't want expanded by string interpolation. -- Just my 0.00000002 million dollars worth, Shawn "Where there's duct tape, there's hope." Cross Time Cafe "Perl is the duct tape of the Internet." Hassan Schroeder, Sun's first webmaster -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/