I ran across a weird (to me) issue today that really slows down a script im running. (in fact it never finishes) The script is a cgi-script. Here is the part that is slowing down, i know this because i can eliminate the slow down, but im wondering why it slowed down in the first place.
...
foreach my $field (sort @$field_order) {
print "\t<TR>\n";
print "\t\t<TH ALIGN=RIGHT>$field :</TH>\n";
for my $i (0 .. $num_recs) {
print "\t\t<TD ALIGN=LEFT>$records->[$i]->{$field}</TD>\n"
+;
}
print "\t</TR>\n";
}
$records is an array of hashrefs of strings, nothing special. The inne loop contains only the one print statement, and that is where the slowdown occurs. If i add the following line, like so:
...
# heres the new line of code
$records->[$i]->{$field} .= "";
print "\t\t<TD ALIGN=LEFT>$records->[$i]->{$field}</TD>\n";
...
then this script runs fast.
I have also tried checking the lengths of each value :
length($records->[$i]->{$field})
and they all are reasonable. I have also taken refs to various parts of this data structure, and looked at it with Data::Dumper, and nothing unusual appears.
So, i am completely perplexed! - but i have found a workaround.
Any insight would be great. If you need more info, let me know.
A co-worker is trying to get mod_perl to work, so that may be it??
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.