in reply to How do read the varibles from a files and do some calculation
Probably it is better to simply use split, so that you don't need to worry about things like the format of the number.
use strict; use warnings; my ($A, $B, $C, $D); while (<DATA>) { chomp; my @parts = split /\|/; print "\$$parts[0] = $parts[1]\n"; eval("\$$parts[0] = $parts[1]"); } print "$A\n"; print "$B\n"; print "$C\n"; print "$D\n"; __DATA__ A|-10 B|20_000 C|20.1234 D|2E-3
Then you can do whatever you want with those variables.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do read the varibles from a files and do some calculation
by ikegami (Patriarch) on Oct 21, 2004 at 18:52 UTC | |
by revdiablo (Prior) on Oct 22, 2004 at 18:02 UTC |