in reply to /e in regexes
The "e" being absent means "treat the replace expression as a double-quote string literal".
$x = '10+4'; print( "$x" ); # 10+4, not 14
The "e" being present means "treat the replace expression as a Perl expression".
The Perl expression $1 evaluates to the value of $1, which is the string 10+4.
$x = '10+4'; print( $x ); # 10+4, not 14
s/.../.../ee is an awful* way of saying s/.../eval .../e.
That means that not only is $1 treated as a Perl expression, so is the value returned by it.
$x = '10+4'; print( eval $x ); # 14
* — In my opinion, something as dangerous as eval EXPR shouldn't be hidden as an simple little "e".
Update: Added illustrative code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: /e in regexes
by waldner (Beadle) on Jun 22, 2008 at 16:44 UTC | |
by moritz (Cardinal) on Jun 22, 2008 at 16:48 UTC | |
by ikegami (Patriarch) on Jun 22, 2008 at 16:59 UTC | |
by waldner (Beadle) on Jun 22, 2008 at 17:02 UTC |