[ABE.pm] Is this safe coding practice?

Faber J. Fedor faber at linuxnj.com
Fri Jun 1 09:25:22 PDT 2007


I don't think this is what Larry, et. al had in mind when they wrote the
parameter passing routines in Perl, but this works for me.  I'm just
wondering if there are any hidden gotchas:

I've got a func that returns the min and max values in an array:

sub getMinMax {
    my @data = @_ ;
    my $stat = Statistics::Descriptive::Full->new(); # a great stats package!
    $stat->add_data(@data);
    return ($stat->min(), $stat->max());
}

and of course, this works fine:

    ($MinY, $MaxY) = getMinMax(@foo);

Is there anything wrong with calling it like this as well:

    ($MinY, $MaxY) = getMinMax(@foo, @bar);

or even as

    ($MinY, $MaxY) = getMinMax(@foo, @bar, $fubar);

assuming you want the min and max values of all the data in @foo, @bar
and $fubar?

AFAICT, it works, but it doesn't seem to be "proper", i.e. you can do
that but you shouldn't do that.

-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the ABE-pm mailing list