>-----Original Message----- <snip> >I have developed a set of scripts on linux that run fine, but I'm >testing out on Windows XP with Apache and ActivePerl, and I've hit a >(probably very simple) problem. > >Put simply, I have a file db.pm which defines a function thus: > ><begin db.pm> >sub db >{ > my $user="xxx"; > my $password="xxx"; > my $database="xxx"; > my $hostname="localhost"; > > my $dsn = "dbi:mysql:$database;$hostname"; > my $dbh = DBI->connect($dsn, $user, $password) or die $!; > return $dbh; >} ><end db.pm> > >and in my script switchboard.pl I have > ><begin switchboard.pl> >#!/usr/bin/perl > >use strict; >use db; > >my $dbh=db; > ><end switchboard.pl> > >All this works fine on linux, but not on Windows. I get: > >[error] [client 127.0.0.1] Bareword "db" not allowed while "strict subs" >in use at ... > >After a bit of searching around, I changed the line to: my $dbh=db(); > >This causes a different error: > >[error] [client 127.0.0.1] Bareword "db" not allowed while "strict subs" >in use at ... >[error] [client 127.0.0.1] Undefined subroutine &main::db called at ... > > >Can anyone see what is wrong?
I believe that it cannot see your db.pm, so you need to add it to your lib path. Something like: use lib qw( ./ ); HTH :Robert _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs