IB2017 has asked for the wisdom of the Perl Monks concerning the following question:
Maybe it is the late hour, but how to sort an array like this
@arrayUnsorted=('page1.html', 'page11.html', 'page2.html', 'page3.html +');
so that I get
@arraySorted=('page1.html', 'page2.html', 'page3.html', 'page11.html') +;
I get my array reading the files inside a directory with
opendir my $dir, "." or die "Cannot open directory: $!"; my @files = readdir $dir; my @filesHTML; foreach (@files){ if ($_ =~ /html/) { push @filesHTML, $_; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Sort array
by choroba (Cardinal) on Mar 05, 2020 at 22:38 UTC | |
Re: Sort array
by AnomalousMonk (Archbishop) on Mar 05, 2020 at 23:54 UTC | |
Re: Sort array
by swl (Prior) on Mar 06, 2020 at 01:27 UTC | |
Re: Sort array
by vinoth.ree (Monsignor) on Mar 06, 2020 at 06:35 UTC | |
Re: Sort array
by johngg (Canon) on Mar 06, 2020 at 11:12 UTC | |
Re: Sort array
by hippo (Archbishop) on Mar 06, 2020 at 14:45 UTC | |
Re: Sort array
by misc (Friar) on Mar 11, 2020 at 18:55 UTC |