in reply to how to place rows information into column (2)
in thread how to place rows information into column?
$file = '0.000000e+000 1.502947e+000 1.162272e-012 1.508957e+001 2.324544e-012 1.508948e+000'; my $regex = { 'first' => qr{^(\S+)}, # anything non-blank from the beginning '^' 'second' => qr{\s+(\S*)} # anything non-blank after the fist blank '\ +s+' }; for(split '\n', $file){ /$regex->{first}$regex->{second}/o # 'o' compiles the regex and # and upon success we take the first column and/or the second one print "Key: $1 and Value: $2\n"; # So hash structure can have $hash{$1} = $2 }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to place rows information into column (2)
by riz (Initiate) on Feb 02, 2005 at 22:06 UTC | |
by sh1tn (Priest) on Feb 02, 2005 at 23:02 UTC |