http://www.perlmonks.org?node_id=694733


in reply to Trimming whitespaces methods

Hi harishnuti,

Here is one way, you can use String::Util module to trim leading and trailing spaces in neat way. You do similarly for array elements. TIMTOWTDI

use String::Util ':all'; $val = ' abc '; # "crunch" whitespace and remove leading/trailing whitespace $val = crunch($val); # remove leading/trailing whitespace $val = trim($val); print ">$val<";

Prasad

Replies are listed 'Best First'.
Re^2: Trimming whitespaces methods
by rovf (Priest) on Jul 01, 2008 at 10:10 UTC
    Another CPAN module for trimming would be Text::Trim.
    -- 
    Ronald Fischer <ynnor@mm.st>