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

Re^5: calling sub with object as param

by afoken (Canon)
on Sep 03, 2015 at 19:27 UTC ( #1140909=note: print w/replies, xml ) Need Help??


in reply to Re^4: calling sub with object as param
in thread calling sub with object as param

should be this:
sub querryDatabase() { my($self, $inputData) = @_; ...

And to make that really good, get rid of the useless and misleading empty prototype:

sub querryDatabase { my($self, $inputData) = @_; ...

To explain that: Method calls bypass prototype checks, so the prototype is useless. And the method expects one parameter (in addition to the implicit object parameter), so using the empty prototype suggesting that the method takes no parameters is misleading and may confuse you (or someone else) later.

General rule of thumb for prototypes in Perl: Don't use them unless you really know what you are doing.

See also: Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2020-08-12 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (65 votes). Check out past polls.

    Notices?