in reply to Getting specific variable data per row.

Your code is a little confusing (what is the point of initialize? What does dummyvoid do? Why is $row a global variable?) but I think this will do what you want.

my $prev_team = ''; while (my $row = $sth->fetchrow_hashref) { if ($row->{team} eq $prev_team) { print "\t$row->{idx}\n"; } else { print "$row->{team}\t$row->{idx}\n"; } $prev_team = $row->{team}; }

Update: Hofmator points out (correctly) that this only works if your SQL query sorts by team name.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you don't talk about Perl club."

Replies are listed 'Best First'.
Re: Re: Getting specific variable data per row.
by c_lhee (Novice) on Nov 28, 2001 at 13:34 UTC

    Here are sample data

    data: ------------------ $team $user $idx $entries A A1 1 1 A A1 2 1 A A1 3 1 A A2 4 1 B B1 5 1 ------------------

    I am trying to display something like this

    display: ---------------------------- TEAM USER ENTRIES ---------------------------- A A1 3 A2 1 ---------------------------- 4 - TOTAL ---------------------------- B B1 1 ---------------------------- 1 - TOTAL ----------------------------