# -- the type of the file can be found by checking if the value # -- of the 3rd field of the 2nd line is a number sub check_field { my ($file_name) = @_; open my $fh, "<$file_name" or die "*** ERROR opening '$file_name': $!"; my @fields; while (<$fh>) { if ($. == 2) { chomp; @fields = split /;/; die '*** ERROR number of fields !=4' unless @fields == 4; last; } } close($fh); return $fields[2] =~ /^\d+$/; }
In reply to advice for reading data from a file by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |