I'm rather confused by your logic. I'm also confused by your problem domain.

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.

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"; }
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.