in reply to Stupid question about regex with string followed variable in replacement
Perl always allows curlies to surround the symbol's name (or expression) following sigils!
So
$txt =~ s/test/${foo}bar/;
instead of
$txt =~ s/test/$foobar/;
HTH =)
Cheers Rolf
( addicted to the Perl Programming Language)
Documentation wasn't easy to find:
from perldata#Scalar value constructors
As in some shells, you can enclose the variable name in braces to disambiguate it from following alphanumerics (and underscores). You must also do this when interpolating a variable into a string to separate the variable name from a following double-colon or an apostrophe, since these would be otherwise treated as a package separator:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Stupid question about regex with string followed variable in replacement
by Anonymous Monk on May 19, 2013 at 22:27 UTC | |
by NetWallah (Canon) on May 19, 2013 at 23:06 UTC | |
by LanX (Saint) on May 20, 2013 at 00:37 UTC | |
by Anonymous Monk on May 19, 2013 at 23:21 UTC | |
by LanX (Saint) on May 19, 2013 at 22:52 UTC | |
by Anonymous Monk on May 19, 2013 at 23:13 UTC | |
by LanX (Saint) on May 19, 2013 at 23:31 UTC |