in reply to Array splitting
The { $a cmp $b } comparison is the default behaviour for sort so doesn't have to be mentioned specifically if you don't wish. You can populate your @A and @trash arrays in one go by eliminating the intermediate @sorted array and pushing onto the appropriate array using a ternary (see Conditional Operator).
$ perl -Mstrict -Mwarnings -E' > my @notSorted = qw{ Beep Ape Circus Arg }; > my( @A, @trash ); > push @{ $_ =~ m{^A} ? \ @A : \ @trash }, $_ for sort @notSorted; > do { > local $" = q{, }; > say qq{@A}; > say qq{@trash}; > };' Ape, Arg Beep, Circus $
I hope this is helpful.
Cheers,
JohnGG
In Section
Seekers of Perl Wisdom