in reply to Re: Re: Hashes and Functions
in thread Hashes and Functions

IMHO, "shift" is the better way to get arguments off of @_. If you start using "shift", you'll never get confused about scalar vs. list context, etc.

So,

my ($cref, $dref) = @_;

becomes

my $cref = shift; my $dref = shift;

Very clean, very easy. No confusion :-)

HTH.

Replies are listed 'Best First'.
Re4: Hashes and Functions
by dragonchild (Archbishop) on Apr 14, 2003 at 17:02 UTC
    Uhhh ... I disagree. It may be cleaner, but I don't think that this style will keep you learning. I believe it is better to directly confront the syntactic issues you have and learn from them than try to avoid them.

    For example, by pushing my$self into confronting list vs. scalar context, I learned more about what context really is. That allows me to take advantage of nifty features like wantarray.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.