use strict; use warnings; use Data::Dumper; my @rows; # Store the rows here my @empty; # If we see a true value we put it here while (<>) { # read a line at a time chomp; # lose the newline my @row=split /;/; # split the line by ; push @rows,\@row; # store the row $empty[$_]||=$row[$_] # Equivelent to saying $empty[$_] or ($empty[$_]=$row[$_]) for 0..$#row; # for each column } print "Empty columns:",join(", ",grep { $empty[$_] } 0..$#empty),"\n"; print Data::Dumper->Dump([\@rows],['*rows']);