I have missed a '$' in the original post.
I do hate to write s/^\s+|\s+$//g for each and each time,just got tired of it.
So I hope perl can have that a string operator, since many script languages 
have that, and it's used universally.

Thanks.

--- jwkr...@shaw.ca wrote:

From: "John W. Krahn" <jwkr...@shaw.ca>
To: Perl Beginners <beginners@perl.org>
Subject: Re: two questions
Date: Tue, 04 Aug 2009 23:24:56 -0700

sys adm wrote:
> 
> 1. why perl doesn't have a built-in strip() function?

Why doesn't BASIC have built-in regular expressions?  Why doesn't C have 
built-in strings?  Why doesn't $LANGUAGE have built-in $FEATURE? 
Because that is the way the language was designed.


> each time I need
> to say $var =~ s/^\s+|\s+//g to strip the blank space before and after
> the variable, specially if this is a CGI var.

That actually strips *all* whitespace from the variable:


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to