Following is the code used in my CGI script.
my $query = $dbh -> prepare("SELECT * FROM invoices WHERE ID = '$ID'");
$query -> execute();
while (my @row = $query -> fetchrow_array()){
print "$row[1] - $row[2] - $row[3]<br>";
}
What If I want to remove dupes from @row? like if $row[2] is similar in multiple records, only one entry should be showed, the duplicates should not appear in the print.
I am aware of grep, but unable to implement it here in While loop.
@row = grep {++$count{$_} < 2} @row;
Any ideas?
my $query = $dbh -> prepare("SELECT * FROM invoices WHERE ID = '$ID'");
$query -> execute();
while (my @row = $query -> fetchrow_array()){
print "$row[1] - $row[2] - $row[3]<br>";
}
What If I want to remove dupes from @row? like if $row[2] is similar in multiple records, only one entry should be showed, the duplicates should not appear in the print.
I am aware of grep, but unable to implement it here in While loop.
@row = grep {++$count{$_} < 2} @row;
Any ideas?