[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] sifting



Hafta think of this one as a pattern too :-)

my @input = qw(Every
                ALPHA_male
                Good
                Boy
                BETA_blocker
                Deserves
                ALPHA_BETA
                Fine
                ALPHA_channel
                BETA_Max
                Apples);
my (@alpha, @beta);
my @result = reverse ((grep { /ALPHA/ ? push (@alpha, $_) && 0
                             : /BETA/  ? push (@beta,  $_) && 0
                             : 1
                             } reverse @input), @beta, @alpha);
print "@result\n";


--
Peter Scott
Pacific Systems Design Technologies


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe