in reply to Re: Breaking out of an 'if'
in thread Breaking out of an 'if'

Can you explain the difference between the two methods of calling?

Replies are listed 'Best First'.
Re^3: Breaking out of an 'if'
by ikegami (Patriarch) on Apr 14, 2005 at 19:55 UTC

    The prototype is ignored when & is used.

    use strict; use warnings; sub testing(\@) { my ($arg) = @_; print("First argument: ", $arg, "\n"); $arg->[5] = 'e'; } my @a = qw( a b c d ); print("Test 1:\n"); testing(@a); print("\n"); print("Test 2:\n"); &testing(@a); print("\n"); __END__ output ====== Test 1: First argument: ARRAY(0x1ab2780) Test 2: First argument: a Can't use string ("a") as an ARRAY ref while "strict refs" in use at ! +.pl line 8 .

    It also varies the behaviour of function calls with no parens:

    sub testing { print("[@_]\n"); } sub test1 { testing; } sub test2 { &testing; } print("Test 1:\n"); test1(); print("\n"); print("Test 2:\n"); test2('moooo'); print("\n"); __END__ output ====== Test 1: [] Test 2: [moooo]