Right sorry if my thing is a bit convoluted. Let me try again. I have two objects using 2 different classes. One is say called $f thats an instance of class "Foobar." The other is $b of class "Blah." They're both modules.

My question would be, can I inside the module for "Blah" access a variable in the main program? That variable also happens to be $f, an instance of "Foobar."

Let me fix my example too.

main code:

use Blah; use Foobar; $b = Blah->new(); $f = Foobar->new(); $b->doSomething;

and inside the Blah module:

sub new { ... } sub doSomething { $f->methodX(); }

And inside the Foobar module:

sub new { ... } sub methodX { does some fun things here }

So basically, method "doSomething" is invoked. I want to be able for "doSomething" to access variable in the main program $f. $f just happens to be an instance of "Foobar."

Thanks!


In reply to Re: Re: accessing subs/methods from the module by shrubbery
in thread accessing subs/methods from the module by shrubbery

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.