not sure how to title this post.
the code below gives the count i need, but i'm having trouble printing the count where i need it, which is in the third position. i've tried splice and other things, but i have to do that before the last statement, so i get a wrong count.
my $accounts_by_id = {};
for (@accounts) {
my($id, $rest) = split /,/, $_, 2;
$accounts_by_id->{$id}->{info} = $rest;
}
for (@purchases) {
my($id, $rest) = split /,/, $_, 2;
push @{$accounts_by_id->{$id}->{purchases}}, $rest;
}
for (@accounts) {
my($id, $rest) = split /,/, $_, 2;
{
my @five = splice
@{$accounts_by_id->{$id}->{purchases}}, 0, 5;
last unless @five;
#I NEED TO COUNT AND PRINT THE NUMBER OF ITEMS IN @FIVE HERE BUT I HAV
+EN'T INCREMENTED THE COUNTER YET
print "$id,$accounts_by_id->{$id}->{info},",
join(',', @five), "\n";
$count =0;
foreach $id(@five){
$count ++;
}
#THIS GIVES ME THE RIGHT COUNT
print "count is: $count endcount";
print "<br>";
redo if @five == 5;
}
}