Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Get three values with an foreach

Quote Reply
Get three values with an foreach
May someone can change this to an easier way, plz ?

Code:
my @cats = $cat_db->select (['Full_Name','Name','Number_of_Links'], { FatherID => $id })->fetchall_list;
my ($output, $url);
my $count = '0';
foreach my $cat(@cats) {
if ($count eq '0'){
$url = $cat_db->as_url($cat);
}
elsif ($count eq '1'){
$output .= qq~<a href="$url">$cat</a>~;
}
elsif ($count eq '2'){
$output .= qq~ ($cat)<br>~;
}
$count++;
if ($count eq '3') {$count = 0};
}




Robert
Quote Reply
Re: [Robert] Get three values with an foreach In reply to
You'll want to use == instead of eq
Quote Reply
Re: [Paul] Get three values with an foreach In reply to
Yes. But the quest is, how could i move inside an array.
Think i should do it with an while instead a foreach;
but at the moment it does what it should do ;-)

Thank you.
Robert