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/

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.