CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [kennychen614] Issues :matching variable $1,$2,... in replacement string: Edit Log



Zhris
Enthusiast

Apr 19, 2011, 12:49 PM


Views: 10212
Re: [kennychen614] Issues :matching variable $1,$2,... in replacement string

Hi,


Code
my $str = q/$1 of 10/;

Using "q" will interprate the string literally as "$1 of 10", therefore in order for $1 to interpolate, you would need to use "qq".

However, since the regular expression hasn't been compiled yet, then $1 will interpolate as an empty string at this point, therefore it won't work as desired anyway.

Personally I would stick to using your working method, afterall theres not really any reason why you need to put the "search" string and "replace" string in their own variables.

Chris


(This post was edited by Zhris on Apr 19, 2011, 12:51 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Apr 19, 2011, 12:50 PM
Post edited by Zhris (Enthusiast) on Apr 19, 2011, 12:50 PM
Post edited by Zhris (Enthusiast) on Apr 19, 2011, 12:51 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives