On Wed, Apr 1, 2009 at 14:23, Chap Harrison <c...@pobox.com> wrote:
> Hi,
>
> Using the DBI module, I've retrieved a row set from a database.  I have an
> $ary_ref with which to access the data.
>
> As I understand it, $ary_ref is:
> a reference to ...
> an array of references to ...
> fixed-length arrays containing the selected cells from each row.
>
> The SELECT statement that produced this result specified three columns to
> return; A, B, and C.
>
> I want to take the values of A and C from each row, concatenate them with
> equal-signs, surround this pair with parens, and join these with commas.
>
> e.g.
>
> (a1=c1),(a2=c2),(a3=c3) ... etc.
>
> I've been trying to do this in one statement, which perhaps isn't advisable,
> nesting join() functions, but I'm failing thoroughly.  Could anyone show me
> the way (or dissuade me; whatever)?

If I understand you correctly, you want a map[1] that feeds a join[2]:

#!/usr/bin/perl

use strict;
use warnings;

my @aref = (
        [qw/a1 b1 c1/],
        [qw/a2 b2 c2/],
        [qw/a3 b3 c3/],
);

print join(", ", map { "($_->[0]=$_->[2])" } @aref), "\n";

1. http://perldoc.perl.org/functions/map.html
2. http://perldoc.perl.org/functions/join.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to