in reply to Instance Module
Basically, a my variable is a lexical varaible. It has nothing to do with packages, so forget about that. Think in terms of lexical scope. A file is a lexical scope. A block is a lexical scope( whatever is inside a pair of { } ). A package is _not_ a lexical scope. It just seems that way, because everyone usually puts one and only one package in a file, basically creating a lexical scope for that package.
So, for your specific example, put my $image inside sub one, and you are game. If you want it to persist each time you call one, do it like this:
Notice the extra set of braces. We have just created a scope for $image, so that one can see it, but two can't. Hope this clears things up a bit, goldclawPackage Pack; { my $image; sub one { ($image)=@_; } } sub two { print $image; }
|
|---|