On Thu, 10 Sep 2009 14:01:36 +0000, Peter Scott wrote:
> Unless it's written by someone whose Perl learning stopped with Perl 4.

Scratch that, I was so focussed on the body of the subroutine I forgot the 
context.

> sub trim { $_[0] =~ s/^\s*(.*?)\s*$/$1/ }

my $trim = sub { $_[0] =~ s/^\s*(.*?)\s*$/$1/ };

I suppose it is used to swap in and out of filter chains.

>>> my $trim = sub {local($_)=shift;
>>>      $$_ =~ s/^\s*//;
>>>      $$_ =~ s/\s*$//;};

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274

-- 
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