note
QM
You've failed again to ask your question appropriately.
<p>
First the diagnoses:
<blockquote><code>
($sub1, $sub2, $sub3) = split (/\_/, @array,3);
</code></blockquote>
<b><code>split</code> doesn't work on an array!!!</b>
<blockquote><code>
while my $elem (@array)
{
($sub1,$sub2,$sub3) = split(/_/, $elem, 3);
# do something here...
}
</code></blockquote>
Now you might have something in <code>$sub3</code>, but this doesn't make any sense either:
<blockquote><code>
$sub3 = sort { $b <=> $a } $sub3;
</code></blockquote>
<b>You can't sort a scalar (well, it doesn't do anything interesting)</b>
<p>
Seems what you really want to do is sort the elements of <code>@array</code> by the last field (numerically), in which case you'll need something like this:
<blockquote><code>
my @a2;
while my $elem (@array)
{
my @fields = split(/_/, $elem, 3);
push @a2, \@fields;
}
my @a3 = sort { $b->[2] <=> $a->[2]} @a2;
</code></blockquote>
But you should really see [How (Not) to Ask a Question].
<div class="pmsig"><div class="pmsig-294463">
<p>-QM<br />
--<br />
Quantum Mechanics: The dreams stuff is made of
</div></div>
487299
487314