my $out_file = "/dicast2-papp/DICAST/smg_data/" . $gfn . ".bin"; #path to binary file my $template = "if262792i"; #binary layout (integer 262792 floats integer) as described in the format documentation above (not sure if this is correct) my $record_length = 4; #not sure what record_length is supposed to represent (number of values in 1st record, or should it be length of variable [4 bytes]) my (@fields,$record); open (FH, $out_files ) || die "couldn't open $out_files\n"; until (eof(FH)) { my $val_of_read = read (FH, $record, $record_length) == $record_length or die "short read\n"; @fields = unpack ($template, $record); print "field = $fields[0]\n"; }