Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Method calling question...

by MeowChow (Vicar)
on May 01, 2001 at 02:23 UTC ( #76794=note: print w/replies, xml ) Need Help??


in reply to Method calling question...

I don't see what the problem is:
package Base; sub method1 { # Insert code here print "Called from class: ", shift, "\n"; }; package Foo; @ISA = qw(Base); package Bar; @ISA = qw(Base); package main; foreach my $classname qw(Foo Bar) { $classname->method1; } ## Output ## Called from class: Foo Called from class: Bar
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
Re: Re: Method calling question...
by satchboost (Scribe) on May 01, 2001 at 02:26 UTC
    There's a reason I was using four files. If you have everything in one file, of course it works cause method1 is scoped within the file. When you have it across several files, it breaks down. :(
      It's not a scoping issue:
      foreach my $classname qw(Foo Bar Oops) { $classname->method1; } ## output ## Can't locate object method "method1" via package "Oops" at C:\Projects +\GPerl\Test\2.pl line 16. Called from class: Foo Called from class: Bar
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print
        Ok. I must've been doing something else wrong. *sighs* I'll putz with it further.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76794]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2023-12-04 03:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (20 votes). Check out past polls.

    Notices?