Melroch has asked for the wisdom of the Perl Monks concerning the following question:
Say I want to insert a numeral "5" between certain characters, so I write:
s/([a-m])([n-z])/$15$2/g;
Now this doesn't work: Perl thinks I'm talking about a variable $15 here and I get an error message. To work around I define a variable $five = 5; and redefine the s/// as
s/([a-m])([n-z])/$1$five$2/g;
Now it works but is there a way to get it to work without that $five variable?
TIA,
/Melroch
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inserting numbers between parenthese matches in regexp
by Happy-the-monk (Canon) on Jun 27, 2004 at 17:01 UTC | |
|
Re: Inserting numbers between parenthese matches in regexp
by dws (Chancellor) on Jun 27, 2004 at 17:17 UTC | |
|
Re: Inserting numbers between parenthese matches in regexp
by Joost (Canon) on Jun 27, 2004 at 17:02 UTC | |
|
Re: Inserting numbers between parenthese matches in regexp
by BrowserUk (Patriarch) on Jun 27, 2004 at 19:25 UTC | |
by grinder (Bishop) on Jun 27, 2004 at 21:26 UTC | |
by BrowserUk (Patriarch) on Jun 27, 2004 at 22:03 UTC |