I try to use 'our' That doesn't seem to present $storage in the other packages
The reason for this is that
$storage is declared into the
main:: package, so isn't a global. If you still want to use as is with your classes you could always access it by it's full path
$main::storage, but that's not a great solution.
I think your best options are either to pass it to the constructor each time or put it in the Source package as a package variable and have the Destination package access it from their e.g
$Source::storage = Storage->new();
# in package Destination
do_stuff_to($Source::storage);
Another option would be to have Destination inherit from Source
package Destination;
@ISA = qw(Source);
...
# main code
$Source::storage = Storage->new();
# Destination can now use $storage, hurrah
Er, nope, that's wrong. Why? Because child classes only inherit methods, and even then it's only through the method lookup done by objects.
HTH
_________
broquaint
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.