#main.pl use strict; use Config::Tiny; use Config::P; my $DATA; open CONFIGFILE2, "imp1.txt" or die $!; { local $/; $/ = undef; $DATA=; } 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;