Sergey Matveev wrote:
Greetings,

On Fri, Feb 19, 2010 at 03:54:27PM -0500, Erik Lewis wrote:

I have to changes all the spaces in a string to +'s.  Is there an
easy way to do this.  The length of the string and the number of
spaces will always be changing.

$string =~ s/ /\+/g;

That is all. All spaces will be replaced.

You don't have to escape a plus sign in a quoted string:

$string =~ s/ /+/g;

Or for a more efficient way:

$string =~ tr/ /+/;



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to