On Tue, Jul 08, 2003 at 01:04:40PM -0400, Paul Kraus wrote:
> Thanks for all good advice. However why is the & in front of 
> the sub routine call a bad idea.

Check:

    % perldoc perlsub

In Perl5, the ampersand changes how the subroutine call is parsed
and executed.  If you use it with parentheses, then prototypes will
be disabled (which is presumably not what you intended).

    sub foo (\@) { print "@_\n"; }
    sub bar {
        foo(@ary);    # passed by reference
        &foo(@ary);   # @ary gets *flattened*
    }


If you use the ampersand without parens, then the called subroutine
"shares" your argument list:

    sub foo { print "@_\n" }
    sub bar {
        &foo;  # like foo(@_);
        foo;   # like foo();
    }

Both of these forms have their (occasional) places, but you should
be aware of what they really do.

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to