If your data is the same (_always_) then you can use a specific regex to get the data out. Or, perhaps more appropriately, to modify your delimiters:
Case 1 - permanent regex:
for my $line (@lines_from_data_file) {
my($idx,$fname,$sname,$loc,$time) = $line =~
/^(\d+),("[^"]+"),("[^"]+"),("[^"]+"),(.*)$/;
}
Case 2 - one-liner to modify delimiters (in place)
perl -i.bak -ne "s/([\d\x22]),/$1.'|'/eg;print" datafile
# for some reason I can't use single quotes for a
# perl -e on Win32 so I have to use \x22 for "
Case 3 - just realised you can use the regex above (slight mod.) for your split.
@data = split /([\d"]+),/;
I still suggest that case 2 is your best option - you're just making more work for yourself if you don't.
"Argument is futile - you will be ignorralated!"
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.