in reply to RE: RE: Re: Perlmonks Code Proxy
in thread Perlmonks Code Proxy

Right hand side, not left:
$str = "Hello world\n"; $str =~ s/o/print "Got an o!\n"/eg; print $str;

Replies are listed 'Best First'.
RE: RE (tilly) 4: Perlmonks Code Proxy
by Boogman (Scribe) on Aug 19, 2000 at 01:49 UTC
    yeah - I was saying that if you matched code on the right side, and then used that code in the eval expression with $1, it wouldnot get executed.

    AKA, saying s/(stuff)/$1/eg would not do anything even if the stuff captured in $1 was perl code.

    $string = "print 'got an o\n'"; $string =~ s/(.*)/$1/eg;
    Doesn't print anything.
      OK, I misunderstood what you were trying to figure out.

      Even so ehis should not be a surprise. Execute the statement $var and nothing happens except that the contents of $var are returned. Same thing with $1. Execute it and it returns the contents of $1 as a string, presumably to be placed back in the original string.

      But try using the modifier /eeg and see what that does. :-)