Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

why can't I do '&$parsers{$key}(arg)'
  • Comment on how to dereference a code reference from a hash value?

Replies are listed 'Best First'.
Re: references
by davorg (Chancellor) on Sep 11, 2001 at 17:06 UTC
Re: references
by suaveant (Parson) on Sep 11, 2001 at 18:08 UTC
    For some reason I'm not sure of, you need to do...
    my $parser = $parsers{$key}; &$parser($arg);
    if you want to do it in that style... -> is just as well, too

                    - Ant
                    - Some of my best work - Fish Dinner

      Or, you could do:
      &{$parser{$key}}($args);

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.