Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Double interpolation of captured substrings

by gaal (Parson)
on Nov 17, 2004 at 09:59 UTC ( #408350=note: print w/ replies, xml ) Need Help??


in reply to Double interpolation of captured substrings

You might consider assigning your matches into an array, and subscripting that programmatically.

my %patterns = ( 123 => [ 1, 2, 3 ], 312 => [ 3, 1, 2 ] ); @matches = $string =~ /regexp/; $string = join "", @matches[ @{ $patterns{$patternkey} } ];
(You need error handling here, of course; and it probably makes sense to promote the scope of %patterns a bit so that it doesn't get constructed every time you enter the sub.)


Comment on Re: Double interpolation of captured substrings
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2015-07-04 09:48 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 (59 votes), past polls