Note to self
Code, cooking, catman
Friday, April 03, 2009
Trim a string in perl
problem:
I am a perl noob and i need trim a string.
solution:
1) if i can modify the actual string:
sub trim {$_[0] =~s/^\s+|\s+$//g}
2)if i don't want it to modify:
sub trim {my $s = $_[0]; $s=~s/^\s+|\s+$//g;return $s;}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment