Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^6: How to call a sub reff from a hash

by NateTut (Deacon)
on Dec 15, 2008 at 22:22 UTC ( [id://730518]=note: print w/replies, xml ) Need Help??

in reply to Re^5: How to call a sub reff from a hash
in thread How to call a sub ref from a hash

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^7: How to call a sub reff from a hash
by ikegami (Patriarch) on Dec 16, 2008 at 01:52 UTC

    $Parameter is not a hash element it is an argument to the procedure reference stored in the hash.

    I know. I didn't use ->{}. I used ->() which calls the referenced sub.

    I'm sorry but that doesn't work either

    Yes it does.

    #!/usr/bin/perl use strict; use warnings; sub Procedure_Name_1 { my($Parm) = shift; print($Parm); } my %Procedures; $Procedures{'ProcName1'} = \&Procedure_Name_1; my $Procedure = 'ProcName1'; my $Parameter = 'Some Value'; $Procedures{$Procedure}->($Parameter);
    >perl Some Value
      I apologize you are right of course, I must have copied wrong before. The real problem here is that I'm not understanding the syntax. Thanks for all the help.

        I'm not understanding the syntax

        ThisCan be written more clearly as

        In this case, the code ref is stored in a hash, so $cref is a hash lookup.

        my $cref = $hash{$k}; $cref->($arg) | v ( $hash{$k} )->($arg); | v $hash{$k}->($arg);
Re^7: How to call a sub reff from a hash
by duckyd (Hermit) on Dec 15, 2008 at 22:36 UTC
    You want:

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-23 20:36 GMT
Find Nodes?
    Voting Booth?

    No recent polls found