You have a file. It will have "EOS" at the last line. (Or, is it between each line? I'll assume the former.) You want to read its data.
Now, what you're doing is creating a string, delimited in a certain fashion, then splitting on that delimitor immediately into a list. Why not just create a list?
Also, your logic in your parser is, well, sketchy.
Basically, read a line. Skip it if we're reading an EOS. (We, essentially, don't care about them as all our data is on one line.) Then, convert the "" or " " into tabs, then remove the extra ", then split on tab and push a listref with our data onto our master data list.my @data; while (<DATA>) { chomp; next if /EOS$/; s/"\s?"/\t/g; s/"//g; push @data, [ split /\t/, $_ ]; } foreach (@data) { my %hash; @hash{qw(First Last Addr City State Phone)} = @$_; print "$hash{First}, $hash{Last}\n"; print "$hash{Addr}\n"; print "$hash{City},$hash{State}\n"; print "$hash{Phone}\n"; print "\n"; }
Then, when we read, we put the data for that line into a hashslice, then access the hash. :-)
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
In reply to Re: Reading in data that is
by dragonchild
in thread Reading in data that is
by basicdez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |