Front page | perl.beginners |
Postings from August 2009
Re: two questions
Thread Previous
|
Thread Next
From:
sys adm
Date:
August 6, 2009 02:33
Subject:
Re: two questions
Message ID:
20090806022938.CD90EBCE@resin11.mta.everyone.net
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.
--- jwkrahn@shaw.ca wrote:
From: "John W. Krahn" <jwkrahn@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:
Thread Previous
|
Thread Next