perlCrazy has asked for the wisdom of the Perl Monks concerning the following question:
Input array is like :
Thanks
How to get new array like this:my @arr = ('TEXT1','TEXT11','TEXT13','TEXT2','TEXT3');
i can do like this:my @newArr = ('TEXT1','TEXT2','TEXT3','TEXT11','TEXT13');
how we can use map here?my @arr1; foreach my $val (@arr) { $val =~ s/TEXT//gx; push @arr1, $val; } foreach my $val1 (sort {$a <=> $b} @arr1) { my $text = 'TEXT'.$val1; push @newArr, $text; }
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need help in sorting the array
by johngg (Canon) on Dec 10, 2009 at 14:56 UTC | |
Re: Need help in sorting the array
by BioLion (Curate) on Dec 10, 2009 at 14:57 UTC | |
Re: Need help in sorting the array
by keszler (Priest) on Dec 10, 2009 at 14:57 UTC | |
Re: Need help in sorting the array
by AnomalousMonk (Archbishop) on Dec 10, 2009 at 20:15 UTC | |
Re: Need help in sorting the array
by bv (Friar) on Dec 10, 2009 at 15:06 UTC | |
by johngg (Canon) on Dec 10, 2009 at 15:25 UTC | |
by bv (Friar) on Dec 10, 2009 at 16:45 UTC | |
by perlCrazy (Monk) on Dec 10, 2009 at 17:08 UTC |
Back to
Seekers of Perl Wisdom