Greetings,
I'm really, really stuck.
I have a text file database, I want to be able assign a variable to each entry in the database and possibly create a new object for each entry on a new line (I hope this doesn't sound too vague).
I know I can do, for example
open(FILE, $file) or die "Cannot open $file: $!\n";
while(<FILE>) {
chomp;($creg, $cname, $attribs) = split(/,/);
}
close(FILE);
But how would I go about creating a new object for each entry (a new entry is on a new line), for example, my text file database is in the format:
UNIQUE ID, NAME, ATTRIBS
UNIQUE ID, NAME, ATTRIBS
etc.
I've been racking my brain to come up with something for days of google'ing, but I've ran out of ideas..
Any help will be lifesaving, litterally! I don't have much time left at all.. :(
maybe something like
foreach $line(@file) {
chomp;($creg, $cname, $attribs) = split(/,/);
$object = $blah->new();
$object->creg($creg);
...
}
I don't know :(
Thank you for your time kind people,
Shibby
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.