Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Calling method inside and outside of package

by lyklev (Pilgrim)
on Oct 28, 2010 at 19:50 UTC ( #868133=note: print w/replies, xml ) Need Help??

in reply to Calling method inside and outside of package

Your example works, because your routine xxx does nothing special. If you have a routine inside a package however, you will either want to do something with the data contained in your object, or you have a generic function that does not access your object's data.

In the first case you would call the function as kcott mentioned, so as

$obj -> xxx("hi");
If you call the function from inside the package, you cannot access the data contained in the object, because you are passing an empty string instead of an object to the function.

If you have a simple function (say, for adding two numbers), you can write a function like you normally would, so without getting the class name from the arguments.

And never call a routine or program test --- there is probably another function or program with that name, which will take you a few hours to find out.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://868133]
[jsbach1]: It's a beautiful day in the neighborhood ........

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2018-04-19 14:49 GMT
Find Nodes?
    Voting Booth?