@names=qw(BARI CAGLIARI FIRENZE GENOVA MILANO NAPOLI PALERMO ROMA TORINO VENEZIA); while (<>) { chomp; chop; ($date,@cities)=split /\|/; for (0..9) { push @{$results[$_]}, $date.$cities[$_]."\n"; } } for $city (0..9) { open OUTPUT, ">$names[$city]"; for $draw (0..$#{$results[$city]}) { if (${$results[$city]}[$draw] !~ /00/) { print OUTPUT ${$results[$city]}[$draw]; } } close OUTPUT; }