[thelist] str_replace equivalent in Perl?

Simon Perry simon.perry at si-designs.co.uk
Fri Feb 20 06:05:41 CST 2004


dave at stemfiction.com wrote:

>Hi all,
>
>Is there an equivalent of PHP's str_replace function in perl? I've
>googled it and found some mentions of it but they don't seem to work how
>they should. Hadn't even looked at perl before monday but I'm working it
>out as I go for this assignment we're doing.
>
>I have data coming as POSTDATA from a form, and the text fields values
>are coming through as word+word2, i.e. all spaces between letters are
>replaced with a +. this is standard, and I'd do a:
>
>str_replace ("+", " ", $variable_name); 
>
>in PHP - can someone be so kind as to explain how to do it in perl?
>
>thanks,
>Dave
>  
>
$variable_name =~ s/+/ /g;

Or see http://www.perldoc.com/perl5.8.0/pod/perlrequick.html

Simon


More information about the thelist mailing list