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 ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-26 03:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found