SPUG: idioms of late

Ronald J Kimball rjk-spug at tamias.net
Mon Jan 18 19:04:13 PST 2010


On Mon, Jan 18, 2010 at 12:04:07PM -0800, Fred Morris wrote:
> $foo->{names} = [ map { my $x = $_; $x =~ s/\.$//o; $x; }
>                       @{$foo->{names}}
>                 ];
> 
> That one munges a listref, stripping trailing dots off of all of the
> elements. The initial "$x = $_;" seems to be necessary. That one seems
> rather pythonic to me. Generally speaking they prefer that I use perl.

If you want to edit the list in place, I think you might as well just edit
it in place.

s/\.$// foreach @{$foo->{names}};

Ronald


More information about the spug-list mailing list