Front page | perl.beginners |
Postings from April 2003
Re: multiple sorts
Thread Previous
|
Thread Next
From:
John W. Krahn
Date:
April 30, 2003 03:17
Subject:
Re: multiple sorts
Message ID:
3EAFA2A6.A53C2252@acm.org
Kevin Pfeiffer wrote:
>
> In article <3EAEF939.2A238EE4@acm.org>, John W. Krahn wrote:
> [...]
> > You don't need a loop for that:
> >
> > my @tmp = splice @AoA, 0, $hdr_flag;
>
> One more quick question - on the back end I put these back into @AoA:
>
> if ($hdr_flag) {
> foreach (@tmp) {
> unshift @AoA, $_;
> unshift @sorted_AoA, $_;
> }
> }
>
> Might there be an easier way here as well (an "unsplice")? :-)
No, unshift does what you want:
perldoc -f unshift
unshift ARRAY,LIST
So this will work:
if ( $hdr_flag ) {
unshift @AoA, @tmp;
unshift @sorted_AoA, @tmp;
}
John
--
use Perl;
program
fulfillment
Thread Previous
|
Thread Next