[Omaha.pm] Intermittent Perl error...

Dan Linder dan at linder.org
Sat Oct 30 09:43:27 PDT 2010


Here is the code from the cgi with line numbers:

  39 use MyPackages::Local;
...

  1965          unless(*check_if_config_file_exists*('datafile.cfg')) {

  1966                  print "The file does not exist. \n";

  1967          }

  1968          unless(*check_if_config_file_readable*('datafile.cfg ')) {

  1969                  print "The file is unreadable.\n";

  1970          }



The error message is always pointing to line 1968.



Both of the *check_if_config_file_** subroutines are defined in the same
module included earlier in the CGI script, and are only used in this
section.



There are no undef commands going on.**



Here’s a few snippets of the MyPackages::Local file.  (Don't laugh - I
haven't maintained this module code, so there are a lot of Perl-Golf code
refactoring I'd like to do...)  [Some names have been changed to protect the
innocent... :-) ]

=== begin ===
  3 package MyPackages::Local;
...
 14 use Exporter;
 15 @ISA    = qw(Exporter);
 16 @EXPORT = qw(
 17         check_if_config_file_exists
 18         check_if_config_file_readable
...
 43 );
...
142 sub check_if_config_file_exists {
143         my ($target) = @_;
144         if (-e "$fl{$target}") {
145                 return 1;
146         }
147         else {
148                 return 0;
149         }
150 }
151
152 sub check_if_config_file_readable {
153         my ($target) = @_;
154         if (-r "$fl{$target}") {
155                 return 1;
156         }
157         else {
158                 return 0;
159         }
160
161 }
...
916 # Make use/require happy
917 #
918 1;
<EOF>
=== end ===

So, nothing much there that I can see, especially considering this exact
same code on the same server will work fine for weeks, then give the
"Undefined subroutine" error for a few minutes in a row, then continue to
work.

I'll keep plugging and double check with the user who reported it.

Thanks,
Dan

2010/10/29 Sterling Hanenkamp <sterling at hanenkamp.com>

> Do any of the subs do some sort of conditional import into main or muck
> with the symbol table?
>
> For example:
>
> use 5.12.1;
> sub foo { say 'test' }
>
> if (rand > 0.5) {
>     undef *{foo};
> }
>
> foo();
>
> 50% of the time will print "test" and the other 50% will print:
>
> Undefined subroutine &main::foo called at test.pl line 8.
>
> On Fri, Oct 29, 2010 at 11:47 AM, Jay Hannah <jhannah at mutationgrid.com>wrote:
>
>> On Oct 29, 2010, at 10:11 AM, Dan Linder wrote:
>> > Status: 500 Content-type: text/html
>> > Software error:
>> > Undefined subroutine &main::MySubroutine called at MyCGI.cgi line 123
>> >
>> > I'm asking my server admin to send me the Apache log files (it's a
>> remote server I don't have access to) - is there anything else to look at?
>>
>> Is it vanilla CGI (perl is executed for every page hit)? mod_perl?
>> fastcgi? other?
>>
>> I'd write a little WWW::Mechanize program to hit it 1000 times and see how
>> many times the error occurs. If you think it's load related somehow (really?
>> eek) then you could use Apache Benchmark (ab) to nail the heck out of it and
>> see if load does indeed cause a problem.
>>
>> Do you have another server with the same software to compare results?
>>
>> HTH,
>>
>> Jay Hannah
>> Software Architect
>> jhannah at mutationgrid.com | http://mutationgrid.com | 1-402-598-7782
>>
>>
>>
>>
>>
>> _______________________________________________
>> Omaha-pm mailing list
>> Omaha-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/omaha-pm
>>
>
>
>
> --
> Andrew Sterling Hanenkamp
> sterling at hanenkamp.com
> 785.370.4454
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>



-- 
***************** ************* *********** ******* ***** *** **
"Quis custodiet ipsos custodes?"
    (Who can watch the watchmen?)
    -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them."
    -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20101030/27ca7f51/attachment-0001.html>


More information about the Omaha-pm mailing list