in reply to help needed with map

Take a look at reduce from List::Util. I think you want something like the third line of this litttle program:
my @foo = ([qw(one two)], [qw(three four)], [qw(five six)]); # use List::Util 'reduce'; # oops: my $str = reduce {"[$a,$b]"} map { reduce {"[$a,$b]"} @$_ } @f +oo; my $str = sprintf "[%s]", join ',', map { sprintf '["%s"]', join '","' +, @$_} @foo; print "--- $str ---\n";
Thanks to Anonymonk for pointing out that I had tested insufficiently. And now I've got the quoting. But I'm not using reduce anymore.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: help needed with map
by Anonymous Monk on Sep 30, 2005 at 00:05 UTC
    #!/usr/bin/perl -w use strict; my @foo = ([qw(one two)], [qw(three four)], [qw(five six)]); use List::Util 'reduce'; my $str = reduce {"[$a,$b]"} map { reduce {"[$a,$b]"} @$_ } @foo; print "--- $str ---\n"; my $seen = 0; $str = reduce { $seen++ ? $a.",[$$b[0],$$b[1]]" : "[$$a[0],$$a[1]],[$$b[0],$$b[1]]" } @foo; print "--- [$str] ---\n";