Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to call a sub-routine ref

by Kenosis (Priest)
on Oct 19, 2012 at 18:33 UTC ( #1000011=note: print w/replies, xml ) Need Help??


in reply to How to call a sub-routine ref

I prefer the arrow operator since it provides a nice, overt dereferencing visual suggesting it's pointing or referring to something else.

Replies are listed 'Best First'.
Re^2: How to call a sub-routine ref
by greengaroo (Hermit) on Oct 19, 2012 at 20:18 UTC

    And if you don't have an argument to pass, isn't it weird to have empty parenthesis?

    $hashref->{'key'}->();

    There are no stupid questions, but there are a lot of inquisitive idiots.
      Why would it be weird? Parens around the arg list, even an empty args list, is the normal way of calling a sub. Omitting parens leads to many problems.

      greengaroo:

      As a long-time C/C++/C# coder, I don't find the empty parenthesis weird. (Though it took me a (very) little while getting used to leaving off parenthesis altogether.)

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1000011]
help
Chatterbox?
[1nickt]: my $x = $aohoaoh->[0]->{' foo'}->[0]->{'bar' }; should work
[thepkd]: not indexing
[thepkd]: getting data out of the ds
[choroba]: it depends. Give more details, please
[thepkd]: i used a series of {}'s but it dont work
[choroba]: You need square brackets for arrays
[GotToBTru]: you can certainly construct a single expression to access any part of the data structure, without using temp variables. but you might make it easier on yourself and any other poor soul who has to understand your code if you do
[thepkd]: to dereference i mean
LanX .oO( oh tempz, oh moretz)
[thepkd]: @GotToBTru Sure. But.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2016-12-06 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.