bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:
Here's the output of this code.#!/usr/bin/perl use strict; my @a = qw( a b c d ); my @z; for (@a) { chomp; s/(d)/new(\1)/; push ( @z, $_ ); } print join ",", @z;
a ,b ,c , new(d)
print join ", ", map { chomp; s/(d)/new(\1)/ } @a;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Better Way of Manipulating Array Elements
by morgon (Priest) on May 19, 2009 at 21:50 UTC | |
by ikegami (Patriarch) on May 19, 2009 at 22:48 UTC | |
by morgon (Priest) on May 20, 2009 at 00:02 UTC | |
by ikegami (Patriarch) on May 20, 2009 at 00:05 UTC | |
by morgon (Priest) on May 20, 2009 at 00:19 UTC | |
by ikegami (Patriarch) on May 20, 2009 at 00:10 UTC | |
by bichonfrise74 (Vicar) on May 20, 2009 at 00:07 UTC | |
|
Re: Better Way of Manipulating Array Elements
by JavaFan (Canon) on May 19, 2009 at 22:32 UTC | |
|
Re: Better Way of Manipulating Array Elements
by LanX (Saint) on May 19, 2009 at 22:06 UTC |