[ABE.pm] Re: Printing an array

Phil Lawrence phil at five-lawrences.com
Tue Apr 26 06:35:11 PDT 2005


I'll second the motion; those var names were killing me.  I didn't 
answer because I couldn't bring myself to try and figure out what you 
were doing!  :-/  sorry.

> $ary_ref = = $dbh->selectall_arrayref($stmt);

if you insist, $aref might be more conventional.  Similiarly, you have 
$href for hash refs.

But a real var name is even better, since we'll see it's an aref when 
you dereference it anyway...

>        $stmt = "select rd.cusip, rd.$_->{weight}, fd.cap
>                 from table1 rd
>                 left join table2 fd
>                 on rd.cusip = fd.cusip
>                 and rd.realdate = fd.realdate
>                 where rd.realdate =\'$date\'
>                 and rd.$_->{weight} is not null";

YMMV, but I think lining up your SQL makes life *so* much easier, e.g.

select rd.cusip, rd.$_->{weight}, fd.cap
   from table1 rd
         left join
        table2 fd
           on rd.cusip    = fd.cusip
          and rd.realdate = fd.realdate
  where rd.realdate =\'$date\'
    and rd.$_->{weight} is not null

OR

SELECT rd.cusip, rd.$_->{weight}, fd.cap
   FROM table1 rd
         LEFT JOIN
        table2 fd
           ON rd.cusip    = fd.cusip
          AND rd.realdate = fd.realdate
  WHERE rd.realdate =\'$date\'
    AND rd.$_->{weight} IS NOT NULL

OR

SELECT rd.cusip
      , rd.$_->{weight}
      , fd.cap
   FROM table1 rd
         LEFT JOIN
        table2 fd
           ON rd.cusip    = fd.cusip
          AND rd.realdate = fd.realdate
  WHERE rd.realdate =\'$date\'
    AND rd.$_->{weight} IS NOT NULL

OR

SELECT rd.cusip
      , rd.$_->{weight}
      , fd.cap
   FROM table1 rd
         NATURAL JOIN
        table2 fd
  WHERE realdate =\'$date\'
    AND rd.$_->{weight} IS NOT NULL


 > Now, if I can figure out how to access
 > the data by name instead of subscript.

That's what hrefs are for.

phil


More information about the ABE-pm mailing list