opensubscriber
   Find in this group all groups
 
Unknown more information…

b : bristolbathpm@bristolbath.org 15 June 2010 • 7:16AM -0400

Re: [BristolBathPM] $len = ($#a1, $#a2)[ @a2 > @a1]; advisable?
by Paul Makepeace

REPLY TO AUTHOR
 
REPLY TO GROUP



Non-assembly language programmers would probably do something like,

use List::Util 'max';
my $length = max(@csv_fields, @import_fields);

or

my $length = @csv_fields > @import_fields ? @csv_fields : @import_fields;

-1 if for some reason you particularly need $#foo

Paul

On Mon, Jun 14, 2010 at 15:46, Lyle <webmaster@cosm...> wrote:
> Hi All,
>   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?
>
> Lyle
>
> _______________________________________________
> BristolBathPM mailing list
> BristolBathPM@bris...
> http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm
>

_______________________________________________
BristolBathPM mailing list
BristolBathPM@bris...
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.