in reply to (Ovid) RE(2): Perlmonks Code Proxy
in thread Perlmonks Code Proxy
The /e causes the right hand side of s/// to be handled as code to eval. Well, since we are deliberately matching Perl code with this regex, this solution tends to choke quite spectacularly.Hmmm... Thats strange. I decided to fool around with it and tried this out:
and it printed outmy $i = 1; my $string = 'print "hello";'; my $content = 'print "hello";$x + 2; print "hello";print "hello";print + "hello";'; $content =~ s/($string)/$1.$i++."\n"/ge; print "$content\n"; eval $string;
It doesn't seem that it executed the print statement that was matched, even though if we hand the string directly to exec, it does print out hello.print "hello";1 $x + 2; print "hello";2 print "hello";3 print "hello";4 hello
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE (tilly) 4: Perlmonks Code Proxy
by tilly (Archbishop) on Aug 19, 2000 at 01:28 UTC | |
by Boogman (Scribe) on Aug 19, 2000 at 01:49 UTC | |
by tilly (Archbishop) on Aug 19, 2000 at 02:42 UTC |