cappabi has asked for the wisdom of the Perl Monks concerning the following question:

I have inherited some custom perl modules from the early 2000s (Perl 5.6.0) that are used to hit a proprietary database on a Windows 2003 Server. I am upgrading to Perl 5.16.3 to start using some new modules. My custom modules work fine when run from the command line, but return an "invalid database handle" error when run through Apache. Maybe this is an apache question, but I feel like it has something to do with the win32 api.pm and how my old modules are calling it or packing the data. Has the code changed significantly since 5.6?

I have another server where I tried upgrading to Strawberry Perl instead of ActiveState, and the issue there is it seems to be hanging when win32 returns the new database object (again not on command line, only in apache). Maybe the object is too big or I have an STOUT problem?

For the record I am not a trained programmer, just a financial analyst, so any advice you have for either scenario would be greatly appreciated!

Thank you!

  • Comment on Calls to win32 hanging in cgi not in command line

Replies are listed 'Best First'.
Re: Calls to win32 hanging in cgi not in command line
by bulk88 (Priest) on Aug 06, 2013 at 20:03 UTC
    "Win32::API" with a file called "API.pm" being used? If so, I might be able to help if you describe more, but you said your not a programmer. I am a maintainer of the Win32::API module.
      Oh my - I feel honored to have your response! Here is a sample of a subroutine that calls the api.pm and is not coming back (the database name is a passed through as a "topic", and to reiterate, this works in the command line):
      my $OpenTopic = new Win32::API ("pmdbf32", "OpenTopic", [P, P], N); sub open { my $self = shift; my $topic = shift || "-NA-"; # Topic Name provided? my ($lpTopic, $Topic, $return, $handle); # Already Open? return (-1) if $self->opened(@_); # If no topic is passed, but one was defined previously # then assign $topic that value $topic = $self->{TOPIC} if ($topic eq "-NA-") and (defined($self-> +{TOPIC})); # Return if empty Topic name return (-1) if ($topic eq "-NA-") and (! defined($self->{TOPIC})); # Allocate/Format the data $lpTopic = pack("L", 0); $Topic = pack("a16",$topic); #This is the line that is failing ***** $return = $OpenTopic->Call($Topic, $lpTopic); # Opened Topic OK? if ($return == 0) { ($self->{HANDLE}) = unpack("L", $lpTopic); $self->{TOPIC} = $topic; } else { return (-1); } return $return; }
      Does this provide any insight? Thank you so much!
        Sorry I'm replying so late,
        my $OpenTopic = new Win32::API ("pmdbf32", "OpenTopic", [P, P], N);
        That is wrong, bare letters aren't letters but subs to run. Put single quotes around the parameter letter codes. And add a ".dll" to dll file name. You dont have to, it makes code easier to read.

        are you running on 64 bit or 32 bit windows? What the the C prototype of that OpenTopic function?