use strict; use Data::Dumper; my $count = 0; while (my @both = grep length, ~~<$fh>, ~~<$fh>) { chomp @both; print Dumper \@both; }