Hopfi has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl @not_sorted = qw(Ape Arg Beep Circus); @sorted = sort {$a cmp $b} @not_sorted; @A = (); @trash = (); foreach(@sorted) { if(substr($_,0,1) == 'A') { printf($_." added to A\n"); push(@A, $_); } else{ printf($_." added to trash!\n"); push(@trash, $_); } } print join(', ', @A)."\n"; print join(', ', @trash)."\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array splitting
by Kenosis (Priest) on Oct 31, 2012 at 21:42 UTC | |
by bimleshsharma (Beadle) on Nov 01, 2012 at 08:05 UTC | |
|
Re: Array splitting
by AnomalousMonk (Archbishop) on Oct 31, 2012 at 22:00 UTC | |
|
Re: Array splitting
by Perlbotics (Archbishop) on Oct 31, 2012 at 22:24 UTC | |
|
Re: Array splitting
by johngg (Canon) on Oct 31, 2012 at 22:50 UTC | |
by Hopfi (Novice) on Nov 01, 2012 at 00:18 UTC | |
|
Re: Array splitting
by tobyink (Canon) on Nov 01, 2012 at 10:13 UTC |