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:
- Define $sl; lexically to the package. This is fine, though the variable has no value
- Attempt to print $l->{'Local_Port'}.
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!