In article <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] (Darin Weeks) wrote:
> I am trying to compare two arrays for a macro building system. I need to
> start with the longest longest element from array 1 (the macros) and then
> compare it to all elements in array 2.
> Is there a simple way to cycle through the macro array by length of the
> element values WITHOUT permanently reordering the array?
if that is what you really want... ;)
you can use a schwartzian transform to pre-compute the lengths,
then sort on the lengths and recover the original string.
my @elements = qw( a ghi df rewq dfghj f dfghjkl );
foreach my $element (
map { $_->[0] }
sort { $b->[1] <=> $a->[1] }
map { [ $_, length ] }
@elements )
{
print "$element\n";
}
--
brian d foy <[EMAIL PROTECTED]> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]