Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Array splitting

by Perlbotics (Chancellor)
on Oct 31, 2012 at 22:24 UTC ( #1001752=note: print w/replies, xml ) Need Help??


in reply to Array splitting

TIMTOWTDI:

use strict; use warnings; my @not_sorted = qw(Ape Arg Beep Circus); my @sorted = sort {$a cmp $b} @not_sorted; my @A = grep { /^A/ } @sorted; my @trash = grep { !/^A/ } @sorted; print join(', ', @A) , "\n"; print join(', ', @trash) , "\n";

You can even include the printf(...) in the grep block, i.e. at the beginning since the result of the block should be determined by the filter expression.
Have a look at split to split an array by position. From the title of your OP, I first thought you meant that...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001752]
help
Chatterbox?
[marto]: 1nickt the worst I'm aware of at the moment :P
LanX .♩..♬ ... Another one bites the Sahara dust ...
marto wonders what fresh hell the firefox update has brought, apart from maxing out CPUs
1nickt was looking into Firefox Extended Support releases yesterday. You don't have to go with the updates!
[erix]: wonderfully red sun here
[LanX]: FF has become a source of instability :(
[1nickt]: erix not so wonderful for the lungs :-(
[erix]: the stuff is pretty high up as I understand it; I have not felt any effect on lungs/breathing

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-10-17 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (230 votes). Check out past polls.

    Notices?