string parsing in perl

I don't know perl at all but I need to parse a string and remove the white spaces out of it. How do I do it?

Say I have "UNIX OS/2 Windows MAC"
and I want to make it "UNIXOS/2WindowsMAC"

how do I do it? Thanks.
hclementsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
guadalupeConnect With a Mentor Commented:
$string =~ s/\s//g;
0
 
guadalupeCommented:
Sorry guess I could have been a little more clear.  This will take the value of $string and replace a the white space characters for null (efectivly removing them) but it will perform the subtitution directly on $string.  If you want to preserve $string do this:

($new_string = $string) =~ s/\s//g;

This copies $string to $new_string and then does the substitution on $new_string, preserving $string.
0
 
guadalupeCommented:
Did that work?
0
All Courses

From novice to tech pro — start learning today.