... open file handles, etc. ... defined(my $first_line = ) or die "reading raw input: $!"; chomp $first_line; my ($first_line_first_field) = split m{ , \s* }xms, $first_line; while (defined(my $following_line = )) { chomp $following_line; my ($following_line_first_field) = split m{ , \s* }xms, $following_line; compare($first_line_first_field, $following_line_first_field); } close RAW or die "closing raw handle: $!";