On Jun 1, 2011 8:16 PM, "rodeored" <in...@reenie.org> wrote: > > This code produces the following 3 lines: > foreach $twords(@topTypes) > { > $output.="<p>".commify_series(@$twords)."</p>"; > } > > Type 7 and Type 8 > > Type 9, Type 5, and Type 4 > > Type 2 > > I only want the first line. But when I try:
You're redefining the $output variable each iteration leaving you with the last element. You might try something like: last if defined @$twords > $output.="<p>".commify_series($topTypes[0])."</p>"; > $output .= <<HTML; > It produces: > ARRAY(0x9045bf0) > ^^ is an array reference. Not an array. > If I try adding the @: $output.="<p>".commify_series(@$topTypes[0])."</ > p>"; > There's no output. > That's why you want to literate over the list and stop at the first defined value. > How do I just get the first line? > BTW, use strict; use warnings