"Michael Goodman" <[EMAIL PROTECTED]> writes:

> Pardon my ignorance but,
> 
>   How do you parse a variable to find every occurrence of a string and
> replace the string with another.  I tried using ~s/ but it doesn't work.

Michael,

It's usually better to post a code example so that we can see what's
going wrong.  However, this quick example does what I think you are
asking for:

#!/usr/bin/perl

use strict;
use warnings;

my $string = "How much wood would a woodchuck chuck if a woodchuck could chuck 
wood?\n";
$string =~ s/wo/qu/g;
print $string;

returns:
How much quod quuld a quodchuck chuck if a quodchuck could chuck
quod?

Note the 'g' tacked on to the end of the substitution...

-RN

-- 
Robin Norwood
Red Hat, Inc.

"The Sage does nothing, yet nothing remains undone."
-Lao Tzu, Te Tao Ching

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to