The first thing I notice, and I will assume it was just a typo, is that you call P::sss( $s );, yet you package p;, which has a different name space than you expect. Again, I'll assume this was a typo.

The second thing that pops out to me is the code execution flow. Let me step through it, and you may see what's happening:
use P;
The package P is compiled and code is executed (I will ignore use strict; module for simplistic sakes). In code execution/compile time it will:
You may seee the issue here. Because the code gets compiled and executed at 'use' time, $sl really hasn't been defined yet, and will therefore not be the hash (or blessed hash) reference you expect it to be.

Now, by then calling P::sss( $s ) the sss routine will then define $s1, print out the exepected contents and return out of the routine. Never again, however, will the print $1->{'Local_Port'} be executed.

Overall, to get what you are looking for, you will have to find a way to define $sl before the first print. Without knowing more about the overall application, I would hate to direct you in the wrong direction. Nevertheless, I hope this helped out with your initial question.

Good Luck!

ha||ta

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 wazzuteke
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.