and that happily prints#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;
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:127.0.0.1 5060
Oh, and I follow derby. The code is really messy.$Config = Config::Tiny->read( 'imp1.txt' );
In reply to Re: How can i pass a variable from a program to a module so that it is accessible to the entire module.???
by holli
in thread How can i pass a variable from a program to a module so that it is accessible to the entire module.???
by sanjay nayak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |