sanjay nayak has asked for the wisdom of the Perl Monks concerning the following question:
imp1.txt contains#main.pl use strict; use Config::Tiny; use Config::P; my $DATA; open CONFIGFILE2, "imp1.txt" or die $!; { local $/; $/ = undef; $DATA=<CONFIGFILE2>; } print $DATA; # Create a config my $Config = Config::Tiny->new(); # Open the config, replace with read and $DATA with filename $Config = Config::Tiny->read_string( $DATA ); # see perldoc Config::Tiny my $s = $Config->{_}; #passing the variable $s to the module p P::sss($s); #package package p; use strict; my $s1; sub sss { $s1= shift; print $s1->{Local_IP};#it works fine } #out of sub routine it is not accesssible. print $s1->{Local_Port};#it doesn't work 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can i pass a variable from a program to a module so that it is accessible to the entire module.???
by holli (Abbot) on Aug 24, 2006 at 13:14 UTC | |
|
Re: How can i pass a variable from a program to a module so that it is accessible to the entire module.???
by shmem (Chancellor) on Aug 24, 2006 at 14:39 UTC | |
|
Re: How can i pass a variable from a program to a module so that it is accessible to the entire module.???
by wazzuteke (Hermit) on Aug 24, 2006 at 13:14 UTC | |
|
Re: How can i pass a variable from a program to a module so that it is accessible to the entire module.???
by derby (Abbot) on Aug 24, 2006 at 13:04 UTC |