# --- push everything into an array --- my @match = (); foreach my $line (@array) { if ($line =~ /\Q$search\E/i) { my ($category,$item_name,$item_price,$item_picture) = split /\|/, $line; push @match, <
$item_name
$item_price
End_of_line } } # --- Print the table --- my $inrow; print "\n"; for (0..11) { # want 12 images $cell = shift(@match) or last; $inrow++, print "" if ($_ % 3) == 0; print "$cell"; $inrow--, print "\n" if ($_ % 3) == 2; } print "\n" if $inrow; print "
\n";