Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Note the description of <code>List::MoreUtils</code>:</p> <blockquote> <p>List::MoreUtils provides some trivial but commonly needed functionality on lists which is not going to go into List::Util.</p> </blockquote> <p>The minmax sub in List::MoreUtils will work but compare numerical values, instead of string lengths. However, minmax can be adapted quite easily to instead compare the lengths of its arguments.</p> <pre><code>sub minmax_stringlength (@) { return unless @_; my $min = my $max = $_[0]; for ( my $i = 1; $i &lt; @_; $i += 2 ) { if ( length($_[$i-1]) &lt;= length($_[$i]) ) { $min = $_[$i-1] if length($min) &gt; length($_[$i-1]); $max = $_[$i] if length($max) &lt; length($_[$i]); } else { $min = $_[$i] if length($min) &gt; length($_[$i]); $max = $_[$i-1] if length($max) &lt; length($_[$i-1]); } } if ( @_ &amp; 1 ) { my $i = $#_; if (length($_[$i-1]) &lt;= length($_[$i])) { $min = $_[$i-1] if length($min) &gt; length($_[$i-1]); $max = $_[$i] if length($max) &lt; length($_[$i]); } else { $min = $_[$i] if length($min) &gt; length($_[$i]); $max = $_[$i-1] if length($max) &lt; length($_[$i-1]); } } return ($min, $max); } </code></pre> <p>Note, I did not write the above, I merely added length in the comparisons where before the mere number was being compared. Unfortunately I could not test this because I do not know how the AutoLoader works and I kept getting:</p> <pre><code>Use of inherited AUTOLOAD for non-method List::MoreUtils::minmax_stringlength() is deprecated at script.pl line 9. </code></pre> <p>So if the OP finds himself using find max very often he could just exercise his license and modify MoreUtils to provide that functionality.</p> <p>If somebody more knowledgeable could verify that the above would work please do.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload