Link to home
Start Free TrialLog in
Avatar of hclements
hclements

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of guadalupe
guadalupe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of guadalupe
guadalupe

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.
Did that work?