pardon my clumsy code...this is my first script with perl, and i've only got 1 programming class like 3 year ago...so hehe i kindna suck at it......
No problem, we're all here to learn.
but i'm really lost in how to push the data i got from the text file into the database.....
I'm not a database guru, but you use DBI yourself, so you should really read its docs. However I suppose you simply want some INSERT's. OTOH you may also want to use some higher level tool, like Class::DBI or DBIx::Class...
also when u said unnecessary for loop, wat would be a better way of doing it? C-style is the only way i have been expose to.
Perl-style is documented in perldoc perlsyn and is almost always appropriate in Perl:
for (1..5) {
Do::Something::with($_);
}
OR how else can i do the if-else statement to make it more efficient?
Did I talk about "efficiency"? It's not a matter of efficiency. It's a matter of expressiveness. However, lotsa ways, also depending on the actual situation. For example hash lookup (possibly in the form of a lookup table) or, in your case and still at a quick glance, I would say even array lookup. |