in reply to Re: Pulling white space off before/after string?
in thread Pulling white space off before/after string?
In what decate was it good practice introducing a dependency on an external module in order to get the exact same two substitutions hidden in a sub:
#--------------------------------------------------------------------- +--------- # trim # =head1 trim(string) Returns the string with all leading and trailing whitespace removed. Trim on undef returns undef. =cut sub trim{ my ($val) = @_; if (defined $val) { $val =~ s|^\s+||s; $val =~ s|\s+$||s; }; return $val; } # # trim #--------------------------------------------------------------------- +---------
If it really bothers you just add one line to your code and be done with it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Pulling white space off before/after string?
by chromatic (Archbishop) on Apr 17, 2007 at 19:18 UTC | |
by Fletch (Bishop) on Apr 17, 2007 at 19:50 UTC |