Hi all,
I need help with mod_perl:
My ENV is redhat ES4 + apache2.0.59 + mod_perl2.

I wrote a small script:
####################
package myconf;

use strict;
use warnings;
use DB_File;
use Fcntl;

use Apache2::Const -compile => qw(:common);
use Apache2::Request ();
use Apache2::Connection ();
use Apache2::URI ();

my $db = "/www/data/myconf.db";
tie my %dbh,'DB_File',$db || die "can not open database\n";
my @title = keys(%dbh);

warn "data count:$#title\n";  ### but in error_log  it is -1

sub handler{
        my $r = shift;
        $r->content_type('text/plain');

        my $req = Apache2::Request->new($r);
        my $file = $req->param('file') || "";
        if (defined $file and exists $dbh{$file}) {
                print $dbh{$file};
                return Apache2::Const::OK;
        }else{
                for (0..$#title){
                        print "$title[$_]<br>\n";
                }
        }
}
1;

__END__

If I run it under command line I will got the data number of db is 41, but
if in apache ,it is -1, and open not failed.

Why?
Thanks!

Sil3nt.

Reply via email to