G'day sheolikar,
Welcome to the Monastery.
"... speed is very slow ..."
I already see replies addressing the primary issue:
you're parsing exportchemchar.csv multiple times.
Follow the advice given and only parse it once.
There's a secondary issue: you're writing your own code to parse your CSV files.
This is one wheel that you shouldn't be attempting to reinvent.
This is a non-trivial task, despite the fact that it often appears trivial at first glance.
All the work has already been done for you: see Text::CSV.
Furthermore, the underlying Text::CSV_XS
is likely to be substantially faster than anything you write yourself:
an added bonus addressing your slow speed problem.
"... and not working ..."
Unfortunately, that sort of error report (if you can call it that) is pretty much worthless.
Sorry if that sounds harsh, but just think about it.
You've provided: no sample input; no actual output; no expected output; no warning or error messages;
and no description of how it's not working.
In short, nothing at all that indicates what problem you'd like us to help you with.
[For future reference, the guidelines in "How do I post a question effectively?" can help with all of this.]
Having said that, there are some issues with your code which may have some bearing on whatever
your problem might be.
I see a number of undeclared variables.
The strict pragma will alert you to this type of problem.
I strongly recommend you use it in all your code.
I also see a number of duplicate declarations of variables.
The warnings pragma will alert you to this type of problem.
I strongly recommend you use it in all your code, as well.
In sub processxref, you have an exit that will never be reached because it's preceded by a return:
return $packrecordval;
exit;
You have two potential issues with the key/value pair 'packreporid => $packreportid'.
The key is probably a mispelling of packreportid (note the missing 't');
and, neither that key (either spelling) nor its value appear to be used anywhere in your code.
Your overall code layout isn't too bad but could be improved.
A consistent indentation style, and removal of extraneous whitespace,
will make the code easier to read.
You'll find the logic is clearer and, accordingly, errors therein will be easier to spot.
perlstyle and perltidy
may help in this regard.
|