Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: Re: using a hash to do substitution?

by tachyon (Chancellor)
on Jun 14, 2001 at 11:02 UTC ( #88313=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foreach $key (keys %hash) {
        $key = quotemeta $key;
        $text =~ s/$key/$hash{$key}/eg;
    }
    
  2. or download this
    use Benchmark;
    
    ...
    Benchmark: timing 100000 iterations of Alternation, Simple loop...
    Alternation:  5 wallclock secs ( 4.12 usr +  0.00 sys =  4.12 CPU) @ 2
    +4271.84/s (n=100000)
    Simple loop: 10 wallclock secs ( 9.72 usr +  0.00 sys =  9.72 CPU) @ 1
    +0288.07/s (n=100000)
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2023-03-22 00:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (60 votes). Check out past polls.

    Notices?