Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Export methods to subroutines

by exussum0 (Vicar)
on Jul 21, 2010 at 14:05 UTC ( #850645=note: print w/ replies, xml ) Need Help??


in reply to Export methods to subroutines

NB: The reason I asked about this is..

I have an object in some controller-ish/test-classish code. Doing $foo->something every other line became tedious. $foo was my star object for interaction, so wouldn't it be nice, similar to Test::More, to have ok(...) available.

The hitch is, $foo is a stateful object, so my class would need to be a singleton. So for some cases, it'd be nice to use my class as

$foo = Foo->new; $foo->bar; $foo->baz;
And at others...
use Foo::ExportedOrSomethingClever; bar(); baz(); ... ..
If the state got in the way and I could not separate things, I could go back to my first example. Ambrus is right, this shouldn't be used all over the place. State plus namespace clashes are a pain.


Comment on Re: Export methods to subroutines
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2015-07-04 20:30 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 (60 votes), past polls