sub check_field { my $file_name = shift; open my $fh, "<$file_name" or die "*** ERROR opening '$file_name': $!"; my @fields = (); while (defined (<$fh>)) { if ($. == 2) { chomp; @fields = split /;/; return 0 unless $#fields == 3; last; } } return 0 if $#fields < 0; return $fields[2] =~ /^\d+$/; }