On Dec 12, 2003, at 11:51 AM, Dan Anderson wrote:


Is there a way to chomp all whitespace both at the beginning and end of
a string?  I was thinking of using a regexp like s[^\s*?][]sg and
s[\s*?$][]sg;  Is there a better way?  (I'm thinking of PHP's trim
function)

the traditional path is


        $line =~ s/^\s+//;
        $line =~ s/\s+$//;

but you could always try say

$thingie =~ s/^\s*\b(.*)\b\s*/$1/;

cf: perldoc perlre


ciao drieux

---


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to