in reply to Calling a function reference with arguments

I think I've fixed my problem, I was not dereferencing a hash as I thought in the line:

my $func_ref=%hash{"my_function"};

Once I fixed that, things seem to work.

Funny error message though, how would you interpret this error message?
  • Comment on Re: Calling a function reference with arguments

Replies are listed 'Best First'.
Re^2: Calling a function reference with arguments
by Joost (Canon) on Apr 17, 2007 at 23:44 UTC
      Yep, it should have been $hash{"my_function"}.
Re^2: Calling a function reference with arguments
by GrandFather (Saint) on Apr 17, 2007 at 23:52 UTC

    I get:

    syntax error at noname.pl line 2, near "%hash{" Execution of noname.pl aborted due to compilation errors.

    with:

    my %hash = (hello => "Hello World\n", my_function => \&my_func); my $func_ref = %hash{"my_function"}; $func_ref-> (\%hash); sub my_func { my $hashref = shift; print $hashref->{hello} }

    so it seems the sample code you provided is not quite the same as the code you tested, or there is a Perl version difference issue perhaps? (I'm using AS Perl v5.8.7)


    DWIM is Perl's answer to Gödel