On Tue, Jun 12, 2001 at 05:56:17PM +0100, Tom Watson wrote:
> I was thinking it might be possible to do this in one line using map......?

Well, there's:

    @new = map { my $tmp = $_; $tmp =~ s/foo/bar/; $tmp; } @original;


OR (this is bad form, you shouldn't use map in void context)

    map { s/foo/bar/ } (@new = @original);


You should really question why you want to do this with map.  If it's for
education, that's fine, learn away; however, if this is to go in production
code, write something more readable.  map is a nice hammer, but not
everything is a nail.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Reply via email to