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

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
  • 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