On Monday, July 15, 2002, at 11:01 , Jeff 'japhy' Pinyan wrote:
> On Jul 15, chad kellerman said:
>
>> I am trying to include my own perl module that is outside the regular
>> @INC array. But my perl script still can not find it.. Any suggestions
>> would be appreciated...
to amp on Jeff's note -
the Script.pm file should be named the same as the package.
hence this should be in Script.pm
>> script.pm
>>
>> package Script;
>> BEGIN {
>> use Exporter;
>> @ISA = qw( Exporter );
>> @EXPORT = qw($serverList);
>> }
>
> Why the BEGIN block? Where'd you pick that up from?
That seems to have been a 'fad' from the perl 5.5.X days,
I remember it being all the rage - note also that he is
using exporter and is trying to export the variable there.
the hx2s -AX Script would have spun out - the expected, and
a frame work of the type - thinned down to the bare bones:
package Script;
require 5.005_62;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw( );
our $VERSION = '0.01';
# Preloaded methods go here.
1;
so we would want to do a few modifications, if the OP is
running a version before 5.005_62, which would give us
package Script;
require 5.005;
use strict;
#use warnings; - this some time freaks older perls
require Exporter;
our @ISA = qw(Exporter);
#
# the old way of use vars - if required all of the ours
# we have here will need to be converted to 'my'....
#
use vars qw/$serverList/;
#
# initialize our globals - one could use 'our' here
# in lieu of the above trick.....
#
$serverList = "/home/user/somefile";
our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
#
# not my preferred course - since one should ONLY export what
# absolutely musts, one really should find the %EXPORT_TAGS model
# more useful in the long run...
#
our @EXPORT = qw($serverList);
our $VERSION = '0.01';
# Preloaded methods go here.
#
# here be subs.....
#
1;
now if the script looked like:
#!/usr/bin/perl -w
use strict;
use lib ".";
use Script;
print $serverList;
it would work....
HTH...
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]