Sun Aug 18 20:24:03 EDT 2002

Hello fellow Perl users,

I would like to know how I can setup an external config file whose
variables I can then use in a perl script.

For example:

File Config:
**********************************************************************
MAXLENGTH=56
USER_LIST="user1,user2,user3"
**********************************************************************

Then access the variables in a Perl program:

File sample.pl
**********************************************************************
#!/usr/bin/perl -w

use strict;
# Somehow source values from file Config

my $a = 50;

if ( $a <= $MAXLENGTH )
{
    $a = $MAXLENGTH + 1;
}

print "@USER_LIST\n";
**********************************************************************

I know that this can be done by setting up Config as Config.pm and get
the variables with a "use Config;" in my sample.pl script.

File Config.pm
**********************************************************************
package Config;
use strict;
 
require Exporter;
our (@ISA,@EXPORT,@EXPORT_OK,$MAXLENGTH,@USER_LIST);
 
@ISA = qw(Exporter);
@EXPORT = qw($MAXLENGTH @USER_LIST);
@EXPORT_OK = qw($MAXLENGTH @USER_LIST);
 
$MAXLENGTH = 56;
@USER_LIST = qw(user1 user2 user3);
**********************************************************************

I however want to use a  non Perl file. Please let me know if this is
possible, or do I have to set up the separate package to do this.

Thank you all for your time.

Andrew.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to