Re: Include variables from external perl script



On Oct 30, 3:34 am, pa...@xxxxxxxxxxxxx (Jeff Pang) wrote:
On 10/30/07, howa <howac...@xxxxxxxxx> wrote:

Consider the example below...

Config.pl
======

#!/usr/bin/perl -w

my $value = "abc";

change 'my' to 'our'.



1;

Script.pl
======
require "Config.pl";
In addition to changing 'my' to our' in Config.pl, you'll also need to
add the 'our $value;' to Script.pl

print $value; # How to do this, beside using .pm?

Thanks.

Here's another option.

Config.cfg
==========
$value = "abc";


Script.pl
=========
#!/usr/bin/perl

use strict;
use warnings;

our $value;
do 'config.cfg';
print $value;

.