I installed Apache::SSI last night as I needed a quick way of including some
costing info in a page (from my dbase) that already used std SSI.
The install worked fine, my extension seems to be fine but when my code
runs, I get an unexpected error.
[Thu Nov 16 21:45:33 2000] [error] [Thu Nov 16 21:45:33 2000] null: Can't
locate object method "selectrow_array" via package "GodZoneSSI" at
/usr/local/godzone/modperl/GodZoneSSI.pm line 27, <GEN0> chunk 1.
The DBI->connect would appear to work, but perl complains it cannot find the
$dbase->selectrow_array function in my code.
The code is pathetically small.
----
Startup script for apache
----
#! /usr/bin/perl
# ========================================================================
# Preload the packages used by the various .epl scripts.
#
# The main apache process will compile these into its name space and they
# will therefore be immediately available to the child apache processes.
# ========================================================================
BEGIN {
use Apache();
use lib ('/usr/local/godzone/modperl');
}
use strict;
# Check that the environment is appropriate
$ENV{ 'GATEWAY_INTERFACE' } =~ /^CGI-Perl/ ||
die("GATEWAY_INTERFACE is NOT Perl !!" );
# Common Packages
use Apache::Registry();
use Apache::Constants();
use CGI qw( -compile :all );
use CGI::Carp();
use DBI;
use Apache::DBI();
# ========================================================================
# That's all folks
# ========================================================================
1;
-----
My SSI Module
-----
#! /usr/bin/perl
# ========================================================================
#
# This module extends the base SSI functionality by adding GodZone
# specific directives.
#
# ------------------------------------------------------------------------
# Modification History
# 16 Nov 2000 AGE First Written
# ========================================================================
package GodZoneSSI;
use DBI();
use Apache::SSI();
@ISA = qw( Apache::SSI );
# ------------------------------------------------------------------------
# Resource Cost Lookup
# ------------------------------------------------------------------------
# <!--#ResCost zone=n code=nnn -->
sub ssi_rescost {
my( $self, $oParm ) = @_;
my( $oDBase ) = DBI->connect( 'dbi:Pg:dbname=admin', '?????', '??????' );
my( $oDBase, $iResCode, $iZone ) = @_;
my( @iAmount )= $oDBase->selectrow_array( <<END_SQL );
SELECT rate_internal, rate_local, rate_national, rate_international
FROM resource
WHERE code = $oParm{ code }
END_SQL
my( $iAmt ) = $iAmount[ $oParm{ zone }];
my( $szAmt ) = $iAmt < 0 ? sprintf( "(\$%.2f)", -( $amt/100 ))
: sprintf( "\$%.2f", ($amt/100));
1 while ( $szAmt =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/);
$oDBase->disconnect();
return( $szAmt );
}
$ENV{ 'PATH' } = '/usr/bin:/bin';
# ========================================================================
# End of Module
# ========================================================================
--
Glen Eustace, Systems Engineer - Networking.
Information Technology Services, Turitea, Massey University, Palmerston
North, NZ.
Ph: +64 6 350 5799 x 2707, Fax: +64 6 350 5607