in reply to How can i pass a variable from a program to a module so that it is accessible to the entire module.???

I stripped your code down to
#main.pl use strict; use warnings; my $s = { Local_IP=>"127.0.0.1", Local_Port => 5060 }; #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}, "\n";#it works fine } #out of sub routine it is not accesssible. print $s1->{Local_Port}, "\n";#it doesn't work 1;
and that happily prints
127.0.0.1 5060
so i think your datastructure doesn't contain what you think it does. Try dumping it with Data::Dumper. Also you don't need to read the config-file yourself. You can simply pass the filename to Config::Tiny:
$Config = Config::Tiny->read( 'imp1.txt' );
Oh, and I follow derby. The code is really messy.


holli, /regexed monk/
  • Comment on Re: How can i pass a variable from a program to a module so that it is accessible to the entire module.???
  • Select or Download Code