Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Interpolation of capture buffers not working when regex stored in variable

by jacklh (Initiate)
on Jun 06, 2013 at 00:58 UTC ( #1037338=note: print w/ replies, xml ) Need Help??


in reply to Re: Interpolation of capture buffers not working when regex stored in variable
in thread Interpolation of capture buffers not working when regex stored in variable

Thank you very much! String::Interpolate worked in conjunction with "replace()" code used by methods 4 & 5. We new about the string literal vs string value, but we didn't know how to "cast" it (not mentioned in any of the docs), so we'd hoped Perl would figure it out from context like it does for so many other type conversions. You have saved us. Many thanks again.


Comment on Re^2: Interpolation of capture buffers not working when regex stored in variable
Re^3: Interpolation of capture buffers not working when regex stored in variable
by jacklh (Initiate) on Jun 06, 2013 at 01:10 UTC
    Here's the modified code for others reference:
    use String::Interpolate qw( interpolate ); ...[snip]... # Method 4: worked! (not global) #my ($before, $after) = $regex =~ m{/(.*)/(.*)/}; #$filename = replace($filename, $before, sub {interpolate($after)},0); # Method 5: worked! (global) my ($before, $after) = $regex =~ m{/(.*)/(.*)/}; $filename = replace($filename, $before, sub {interpolate($after)},1);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-12-25 17:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (161 votes), past polls