in reply to Re: array with s///g command
in thread array with s///g command

I like brief too ... why not simply:?
my @array2 = map { s/\s+//g; $_ } @array1;

Update  Whoops, now I see ... it's because you'd be changing the original array.  Still, I like the brevity of something like:

my @array2 = map { (my $x = $_) =~ s/\s+//g; $x } @array1;

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^3: array with s///g command
by GrandFather (Saint) on Jul 30, 2007 at 00:28 UTC

    Because that mangles @array1 - $_ is aliased to each element from @array1 and the substitution clobbers the original value


    DWIM is Perl's answer to Gödel