s_mile has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
Is there a "smart way" :) to remove both the leading and trailing spaces in a string?
One way I know is as below:
Is there a way to do the same in just one statement?$val=" Smart Way "; $val=~s/^\s+//; $val=~s/\s+$//; print '>'.$val.'<'; # shld give me >Smart Way<
'Ask and ye shall recieve. Seek and ye shall find'.
Blessings
s_mile
update (broquaint): tidied up formatting + removed <br> tags from <code> tags
|
---|
Back to
Seekers of Perl Wisdom