Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Double interpolation of captured substrings

by bobf (Monsignor)
on Nov 17, 2004 at 09:37 UTC ( #408346=perlquestion: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $newstring = munge_string( 'one_two_three', '312' );
    
    ...
    
        return $patterns{$patternkey}; # want 'threeonetwo', got '$3$1$2'
    }
    
  2. or download this
    $string =~ s/(\w+)_(\w+)_(\w+)/$patterns{$patternkey}/e;
    print $string; # '$3$1$2'
    
  3. or download this
    $string =~ s/(\w+)_(\w+)_(\w+)/$3$1$2/;
    print $string; # 'threeonetwo'
    
  4. or download this
    $string =~ s/(\w+)_(\w+)_(\w+)/join( '', $3, $1, $2 )/e;
    print $string; # 'threeonetwo'
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2015-07-05 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls