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
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 $col_width = ( sort { $b <=> $a } map { length } ( #sort lengths (keys %lists, map { @$_ } values %lists) + ) )[0] + 2; #2 is the padding
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;
Back to
Seekers of Perl Wisdom