On 20 Jun, 14:43, (e-mail address removed) wrote:
That makes sense.
What makes sense? Please quote appropriate context, such that people know
what you are responding to.
I only ask because page 182 of perl best practices
recommends named arguments are parsed like this:
sub padded {
my ($arg_ref) = @_;
Personally I would prefer
my $arg_ref = shift;
because your method becomes a pain when dealing with more than one
parameter.
instead of:
sub padded {
my %arg = @_;
But those are totally different animals.
In the first sub you would be passing a reference (to e.g. an array or
hash), while in the second example you are passing the hash itself.
or even what I would have though:
my $arg_ref = \@_;
Well, that's yet another beast that has nothing to do with either of the
first examples. Of the top of my head I cannot think of a useful example
when you would want to create a reference to the parameter list.
because non matched pairs causes a compile time error on the first and
Really?
a run time error on the second.
Sure. When assigning a hash like that then it will only work if you got
key/value pairs.
I'm not sure why the first is better than the third?
They are different animals that do different things.
jue