http://qs1969.pair.com?node_id=684927

Boldra has asked for the wisdom of the Perl Monks concerning the following question:

I have a little utility to print the differences between two arrays. I pass the sub a hash (%lists), with the values being array refs. The code below calculates how broad to make the columns on the output, so it selects the longest word from either the keys to the hash or the elements of the array, then adds two for padding
my $col_width = ( sort { $b <=> $a } map { length } ( #sort lengths (keys %lists, map { @$_ } values %lists) + ) )[0] + 2; #2 is the padding
I just think I've gone a bit too far, and this could be a problem for my colleagues in the future. Can anyone suggest a way of making the above code more readable? The input looks something like this:
my %lists; my @amazon = qw(hot tropical humid wet); my @sahara = qw(hot hot tropical big); $lists{"The Amazon is"} = \@amazon; $lists{"The Sahara is"} = \@sahara;


- Boldra