in reply to Re: Re (tilly) 2: optimized switch case
in thread optimized switch case

I am referring to the fact that, as documented in perlsub, calling &foo shares @_ with the current package. Calling it with parentheses gives it its own argument list. The following demo script may give you an idea what this means:
#! /usr/bin/perl use strict; use vars qw($indent); $indent = ''; print "Here is how things go without an &\n"; demo_no_amp(1..5); <STDIN>; print "Here is how they go with an &\n"; demo_with_amp(1..5); <STDIN>; print "And with explicit argument passing\n"; demo_explicit_args(1..5); <STDIN>; print "Done\n"; sub demo_no_amp { local $indent = $indent . " "; while (@_) { my $arg = shift; print $indent, "Without &, '$arg'\n"; demo_no_amp(); } } sub demo_with_amp { local $indent = $indent . " "; while (@_) { my $arg = shift; print $indent, "With &, '$arg'\n"; &demo_with_amp; } } sub demo_explicit_args { local $indent = $indent . " "; while (@_) { my $arg = shift; print $indent, "With explicit args, '$arg'\n"; demo_explicit_args(@_); } }
Puzzle out why those three cases are so different and you will understand why I think the second one is dangerous.