On Mon, Jun 14, 2010 at 11:46:55PM +0100, Lyle wrote:
> This technique came up at one of the meets. I just used this piece of
> code in a project:-
> my $length = ($#import_fields, $#csv_fields)[ @csv_fields > @import_fields];
> Is it advisable though from a maintenance and readability point of view?
No. Either of these is clearer IMO:
$length = ($#csv_fields > $#import_fields) ? $#csv_fields : $#import_fields;
or, preferably:
use List::Util qw(max);
$length = max($#csv_fields, $#import_fields);
also, $length is maybe a bad choice of variable name. $#array is *one
less than* the length of the array assuming that you're not playing
games with $[.
--
David Cantrell | semi-evolved ape-thing
It's my experience that neither users nor customers can articulate
what it is they want, nor can they evaluate it when they see it
-- Alan Cooper
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm