in reply to Re^2: 'Variable' sub names
in thread 'Variable' sub names

Hi,
or so:
foreach my $product (@products) { &{$subs{$product}}; }
then one can see better that it is a sub call.
Regards,
svenXY

Replies are listed 'Best First'.
Re^4: 'Variable' sub names
by Fletch (Bishop) on Sep 15, 2005 at 13:48 UTC

    Keep in mind that your example will call the coderef in $subs{$product} with the current contents of @_ just as if you'd called &namedsub;. If you want to pass an empty argument list you still need the parens: &{ $subs{ $product } }( ). See perldoc perlsub for more details.

Re^4: 'Variable' sub names
by revdiablo (Prior) on Sep 15, 2005 at 17:01 UTC
    then one can see better that it is a sub call

    Perhaps one (since you count as one, I presume) can better see that, but I would think the general Perl-using population understands $foo->() to be a subref call. And even if I'm wrong about that, well, I just think it looks better. :-)

Re^4: 'Variable' sub names
by merrymonk (Hermit) on Sep 15, 2005 at 16:13 UTC
    Many thanks both work well.