Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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: (13)
As of 2014-12-18 09:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (48 votes), past polls