Wednesday, January 5, 2011

Perl: function to trim string leading and trailing whitespace

use String::Util 'trim';
my $str = "  hello  ";
$str = trim($str);
print "string is now: '$str'\n";

No comments: