[Israel.pm] Perl Advocacy
Levenglick Dov-RM07994
DovL at freescale.com
Mon Dec 27 07:55:42 PST 2004
> Worse than that there is no trim that would remove spaces from the
> beginning and the end of a string.
Why not:
$str =~ s/(^\s*|\s*$)//g;
Best Regards,
Dov Levenglick
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of Offer Kaye
Sent: Monday, December 27, 2004 5:51 PM
To: Perl in Israel
Subject: Re: [Israel.pm] Perl Advocacy
On Mon, 27 Dec 2004 16:31:26 +0200, david istermann <interdist at gmail.com> wrote:
> What bugs me most is that in Perl there is no equivalent for PHP's str_replace:
>
> $newstr = str_replace( array('<', '>', '&'), array('<', '>',
> '&'), $oldstr);
>
my %repl = (
'&' => '&',
'>' => '>',
'<' => '<'
);
(my $newstr = $oldstr) =~ s/(<|>|&)/$repl{$1}/g;
I leave wrapping this in a subroutine called str_replace that builds
%repl and the right side of the s/// operator as a (trivial) excercise
for the reader...
Point is, I agree with the point brought up in the pages critisizing
PHP - having over 3000 functions, versus Perl's ~200, doesn't make it
into a richer or better language... on the contrary, IMO.
> Worse than that there is no trim that would remove spaces from the
> beginning and the end of a string.
I didn't understand this, Gabor. Please explain.
--
Offer Kaye
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl
More information about the Perl
mailing list