in reply to Read fortran list output
use strict; use warnings; use Data::Dumper; my @matrix; while (<DATA>){ chomp; if (m/^[A-Z]/){ push @matrix, [$_]; } else { push @{$matrix[-1]}, $_; } } print Dumper \@matrix; __DATA__ C -2.3242E-003 1.32423 0.34243E+002 ..etc... -3.23134 H more numbers
For each line that begins with an upper case letter it pushes a new array reference onto @matrix, and for all other lines it simply pushes the data onto the last array in @matrix.
If you have to deal more with Fortran output, take a look at Fortran::Format.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read fortran list output
by pjotrik (Friar) on Jul 30, 2008 at 10:33 UTC | |
by moritz (Cardinal) on Jul 30, 2008 at 10:53 UTC |