in reply to Re: Quick question on a Perl Code!
in thread Quick question on a Perl Code!

They are subroutines, I just didn't bother to copy and paste the whole code

Replies are listed 'Best First'.
Re^3: Quick question on a Perl Code!
by ikegami (Patriarch) on Jul 13, 2011 at 23:04 UTC

    Reread what he said.

    Arguments are what you pass to a subroutine. They're not being passed to the subroutine as you said. They're part of the subroutine's declaration.

Re^3: Quick question on a Perl Code!
by Anonymous Monk on Jul 14, 2011 at 03:25 UTC
    I'll elaborate
    sub fudge($){ print @_ }
    that is a function declaration -- it doesn't print anything
    fudge(1); fudge 2;
    those are function calls, it prints 1 then prints 2

    If you wrote

    fudge 1,2;
    the prototype ($) ensures fudge only gets 1 argument

    If you try to force the issue with

    fudge(1,2);
    You'll get an error
    $ perl -le " sub fudge($){print @_} fudge(1,2); Too many arguments for main::fudge at -e line 1, near "2)" Execution of -e aborted due to compilation errors.
    Next time, when you get links, follow them, read them, its what we all do :)

      Thanks, I am a newbie just a week programming with Perl and some stuff are still confusing to me! THANKS :o)