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

Re: Mixing OO & non OO code in a module

by hv (Parson)
on Jun 06, 2006 at 12:44 UTC ( #553800=note: print w/ replies, xml ) Need Help??


in reply to Mixing OO & non OO code in a module

I'd normally make such things class methods - if I don't, I find I'm always forgetting to type My::Class::function(...) instead of My::Class->function(...), and it becomes a lot more convenient if I have the classname in a variable:

my $class = "My::Class"; my @coords = $class->look_at(something);

Hugo


Comment on Re: Mixing OO & non OO code in a module
Select or Download Code
Replies are listed 'Best First'.
Re^2: Mixing OO & non OO code in a module
by jdhedden (Deacon) on Jun 06, 2006 at 16:25 UTC
    If your class doesn't get inherited, you can do it both ways using:
    sub function { # Allow calling as a subroutine or class method shift if ($_[0] eq __PACKAGE__); ... }
    If you're doing inheritance, you'd need something more involved, but you get the idea.

    Remember: There's always one more bug.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2015-07-28 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (251 votes), past polls