Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Replacing string with regexp without using modules

by pc88mxer (Vicar)
on Aug 05, 2008 at 22:51 UTC ( #702518=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub prog_replace_string {
      my ($replace_this, $with_this, $string) = @_;
      $string =~ s{\Q$replace_this\E}{$with_this}g;
      $string;
    }
    
  2. or download this
    sub replace_vars {
      my ($string, $hash) = @_;
    ...
    
    my %vars = ( a => 1, b => 22, c => 333 );
    print replace_vars('a: $a, b: $b, c: $c', \%vars);
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2015-07-03 18:43 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 (55 votes), past polls