Anonymous user
Compare length of two strings: Difference between revisions
→{{header|Phix}}
(Added XPL0 example.) |
|||
Line 497:
6 Pascal
6 Foobar</pre>
=={{header|Perl}}==
<lang perl>#!/usr/bin/perl
use strict; # https://rosettacode.org/wiki/Compare_length_of_two_strings
use warnings;
for ( 'shorter thelonger', 'abcd 123456789 abcdef 1234567' )
{
print "\nfor strings => $_\n";
printf "length %d: %s\n", length(), $_
for sort { length $b <=> length $a } split;
}</lang>
{{out}}
<pre>
for strings => shorter thelonger
length 9: thelonger
length 7: shorter
for strings => abcd 123456789 abcdef 1234567
length 9: 123456789
length 7: 1234567
length 6: abcdef
length 4: abcd
</pre>
=={{header|Phix}}==
|