Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: $1 in variable regex replacement string

by tadman (Prior)
on Feb 14, 2003 at 03:26 UTC ( #235168=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: $1 in variable regex replacement string
in thread $1 in variable regex replacement string

I'm not sure why you're using a hash there when this should do the trick:
sub safeswitch { no strict 'refs'; my @P = map { $$_ } 0..@+; $_[0] =~ s/\$(\d+)/$P[$1]/g; $_[0]; }
As far as I can tell, you're only using %seen to count?

Replies are listed 'Best First'.
Re: Re: $1 in variable regex replacement string
by belden (Friar) on Feb 15, 2003 at 01:01 UTC
    Good point. I originally wrote it using a hash, then a few minutes later discovered almost the exact same thing when I followed jsprat's link in this node. I thought about updating my code, but then decided it was buried so deep nobody would find it anyway ;)

    setenv EXINIT 'set noai ts=2'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://235168]
[ambrus]: wait. I understand no wife and children, but how do you not have to pay for a house?
[hippo]: I had a low-paid job about 20 years ago and seriously considered going down to a 3-day week. Would have worked 60% of the time for about 80% of the cash.
[Corion]: ambrus: Well, I pay rent, but don't own a house with variable/ unforeseeable costs
[hippo]: The thesholds/benefits balance at the time was nuts.
[hippo]: But that doesn't last because, you know ... politicians. :(
[Corion]: hippo: Yeah, if you still get enough money to get by and don't have expensive hobbies or other fixed costs that can work out well
[ambrus]: ah good. I pay only rent too. but that still costs significant money.
[Corion]: ambrus: Yes, but that is already budgeted for

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2017-09-21 15:17 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (249 votes). Check out past polls.