in reply to Re: Re: Re: Fastest way to compare multiple variables?
in thread Fastest way to compare multiple variables?
If you could make that instead:use CGI; @array1 = param('datalist1'); @array2 = param('datalist2'); @array3 = param('datalist3');
Then we can compare their lengths with:my %data = map { $_ => [param $_] } qw(datalist1 datalist2 datalist3);
See how much easier? Regularity in variable names is almost always a sign that they should be part of a larger structure instead.sub compare { my @lengths = map { scalar @{$data{$_}} } qw(datalist1 datalist2 dat +alist3); my $first = shift @lengths; $first == $_ or return 0 for @lengths; return 1; }
-- Randal L. Schwartz, Perl hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Re: Fastest way to compare multiple variables?
by mikfire (Deacon) on May 15, 2001 at 23:10 UTC | |
Re: Re: Re: Re: Re: Fastest way to compare multiple variables?
by Anonymous Monk on May 15, 2001 at 22:05 UTC | |
(dkubb) Re: (5) Fastest way to compare multiple variables?
by dkubb (Deacon) on May 18, 2001 at 12:22 UTC |
In Section
Seekers of Perl Wisdom