Do you know where your variables are? | |
PerlMonks |
Re: remove both leading and trailing spacesby Ordinary_User (Beadle) |
on Sep 26, 2003 at 21:09 UTC ( [id://294543]=note: print w/replies, xml ) | Need Help?? |
Given that $val holds the text as you describe in your code, I'd be using the following: $val =~ s/ //g; This will remove all "blanks" from the string and replace them with "nothing", thus removing all blanks from the string, in one swift stroke. The "g" is important! Without it, it will only remove one blank from the string.
In Section
Seekers of Perl Wisdom
|
|