Lori713 has asked for the wisdom of the Perl Monks concerning the following question:
So far, as I try to run the report, my timestamp prints look like this (the first 100 rows):#!/usr/local/bin/perl5_8 use strict; use ncw_com_library; # contains common subs (commify, timeo +ut, etc.) use HTML::Template; use Time::Local; use DBI; use CGI ':standard'; my $CGI = CGI->new; # Clear buffers and set up web page (required) $|=1; open STDERR, ">&STDOUT"; # SNIP there are ~25,000 unique keys in my control table and I have +snipped # out the SQL and database calls that generate my control table datase +t for # those since they are returning results in a timely fashion based on # timestamps printed while fetching and executing SQL. my ($key, %col_cbud, %col_encu, %col_fytd, %col_proj, %ctrl_tbl, @loop +_data); foreach $key ( sort keys %ctrl_tbl ) { my %row_data; # Gimme a timestamp so I can see how long each row takes my ( $sec1,$min1,$hour1,$mday1,$mon1,$year1,$wday1,$yday1,$isdst1 ) = +localtime; print "during foreach loop hour min sec $hour1 $min1 $sec1 xxx key is +$key <br>"; $row_data{col_proj} = $key; $row_data{col_cbud} = $col_cbud{$key}; $row_data{col_fytd} = $col_fytd{$key}; $row_data{col_encu} = $col_encu{$key}; # Add each hash row to loop for template push(@loop_data, \%row_data); } # Pass parameters and variable values from @loop arrays to template; p +rint report $template->param( passdata => \@loop_data, ); print $template->output();
We are beginning to see more and more issues with pages timing out as our co-workers ask for more sophisticated programs (I work at a public university). I think we need to start looking into alternative ways to address this issue and come up with a coding method to incorporate into the applications we're writing.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbefore foreach loop hour min sec +11 13 44 during foreach loop hour min sec 11 13 45 xxx key is 649001 during foreach loop hour min sec 11 14 43 xxx key is 649001-60426-F SNIP during foreach loop hour min sec 12 3 44 xxx key is 660062-05279 during foreach loop hour min sec 12 4 19 xxx key is 660062-15279
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Foreach loop takes a long time to process and my report times out before page is rendered
by GrandFather (Saint) on May 19, 2011 at 01:41 UTC | |
|
Re: Foreach loop takes a long time to process and my report times out before page is rendered
by Anonymous Monk on May 18, 2011 at 17:20 UTC | |
|
Re: Foreach loop takes a long time to process and my report times out before page is rendered
by Neighbour (Friar) on May 19, 2011 at 07:21 UTC | |
|
Re: Foreach loop takes a long time to process and my report times out before page is rendered
by jacaril (Beadle) on May 18, 2011 at 16:51 UTC |