in reply to Re: Declaring a code ref with arguments
in thread Declaring a code ref with arguments

His argument passing is wrong but it sounds like you are saying that this:

my %hash = ( foo =>\&do_foo, bar =>\&do_bar, );

is wrong, (correct me if I'm misinterpreting your post) which I'm not sure where you find that in perlref as that works, even while using strict. To pass the arguments you can do this:

$hash{foo}->('foo','bar','baz');
Lobster Aliens Are attacking the world!

Replies are listed 'Best First'.
Re: Re: Re: Declaring a code ref with arguments
by cianoz (Friar) on Aug 05, 2003 at 14:55 UTC
    no, at all, if you look carefully at what he posted you'll find this:
    %hash = {no_arg => \&print_me, with_arg => \&print_me("Hello World, again!\n" };
    as you can see he uses curly brackets to build a hash and lacks right parenthesis just after "Hello World, again!\n"
    what i say is that this code will never work (maybe is just a wrong trascription) and that you can't do
    bar =>\&do_bar("argument")
    so you have to do
    bar => sub { do_bar("argument") }
    that's all..
    update of course (foo => \&foo) with no arguments is perfectly legal..