Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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?
[MidLifeXis]: heh.
[MidLifeXis]: Most likely it is a code that some undocumented system, hidden behind layers of IT, deep in the bowels of the building under the machine room floor, reads that code to keep a presence switch from going off. :-b
[MidLifeXis]: I think I forgot "running on a farm of commodore 64, vic 20s, trs 80s, and apple ]|[e systems"
[GotToBTru]: oh I know what it is .. but it is a number only slightly useful to me and of no possible use to our customer
[MidLifeXis]: Whew - you just saved the free world. <o)
[GotToBTru]: i guess it's a placeholder, the code will only fill it in if there is nothing else to use
[GotToBTru]: but then .. if you have nothing to say, why not say nothing?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2017-01-20 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (176 votes). Check out past polls.