in reply to (Solved) Exporter not behaving as expected
@rry isn't declared in case 1 because you didn't export anything (@EXPORT = ();).
Case 2 prints zero since you never assign anything to the array named rray in the MyModule namespace. my creates a lexical variable (i.e. one that's only seen in the lexical scope where it's declared), not a package variable (i.e. one that's located in a package and visible everywhere).
Just like your script can't see the lexical variable since it's out of scope, Exporter can't see it either. As such, Exporter exports package variables. Case 3 is therefore exports the same variable that you accessed in case 2, a package variable to which you never assigned anything.
Solutions:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Exporter not behaving as expected
by davies (Monsignor) on Mar 27, 2015 at 18:14 UTC | |
by ikegami (Patriarch) on Mar 27, 2015 at 18:19 UTC | |
by LanX (Saint) on Mar 27, 2015 at 20:45 UTC |