You have a range of options depending on how typical the data you have shown is. split could be used to break up the line into the list of comma separated strings and the tr operator (look for tr/ in the Regexp Quote-Like Operators section) could be used to clean up the first field.
What you do then depends a lot on what you want to do with the data subsequently. Shoving the values into two separate arrays is unlikely to be the most useful technique. More likely you would shove the data into a hash keyed on the first field if you want to look up values, or push data pairs to an array if you want to run through the data performing some calculation on it. Consider:
use strict; use warnings; my @data; while (<DATA>) { chomp; my ($first, $second) = split ','; next unless defined $second; $first =~ tr/+//d; push @data, [$first, $second]; } print join "\n", map {"$_->[0], $_->[1]"} @data; __DATA__ 249+69,775.83 249+67,775.93 249+65,776.11
prints:
24969, 775.83 24967, 775.93 24965, 776.11
In reply to Re: Read from file to two arrays.
by GrandFather
in thread Read from file to two arrays.
by Offshore_Worker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |