andri85 has asked for the wisdom of the Perl Monks concerning the following question:
[photon1, c] = fread(fidin, [1], 'int8'); if (photon1>0) [readout(1,1:3), c] = fread(fidin, [3], 'double'); [readout(1,4:5), c] = fread(fidin, [2], 'int32'); [readout(1,6), c] = fread(fidin, [1], 'double'); end
read(BIN_DATA, $bin_data, $short_int_size); # Convert from binary to a numeric value $photon1 = unpack('C', $bin_data); if ($photon1>0) { read(BIN_DATA, $bin_data, $double_size); $x1 = unpack('f', $bin_data); read(BIN_DATA, $bin_data, $double_size); $y1 = unpack('f', $bin_data); read(BIN_DATA, $bin_data, $double_size); $z1 = unpack('f', $bin_data); read(BIN_DATA, $bin_data, $int_size); $obj_scatt1 = unpack('L', $bin_data); read(BIN_DATA, $bin_data, $int_size); $coll_scatt1 = unpack('L', $bin_data); read(BIN_DATA, $bin_data, $double_size); $en1 = unpack('f', $bin_data); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: read + unpack
by Anonymous Monk on May 06, 2009 at 01:34 UTC | |
by andri85 (Novice) on May 06, 2009 at 22:42 UTC | |
|
Re: read + unpack
by citromatik (Curate) on May 06, 2009 at 07:14 UTC | |
by andri85 (Novice) on May 06, 2009 at 22:51 UTC | |
|
Re: read + unpack
by Anonymous Monk on May 06, 2009 at 12:52 UTC | |
by andri85 (Novice) on May 06, 2009 at 21:09 UTC |