Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Perl - Sort hash of filenames by file extension
#perl 5.22.1 use strict; use warnings; use 5.010; my ($prev_ext, $current_ext); my %planets = ( 'Mercury.txt' => 0.4, 'Venus.dic' => 0.7, 'Earth.doc' => 1, 'Mars.jpg' => 1.5, 'Ceres.png' => 2.77, 'Jupiter.vmw' => 5.2, 'Saturn.ttf' => 9.5, 'Uranus.gif' => 19.6, 'Neptune.hlp' => 30, 'Pluto.doc' => 39, 'Charon.tif' => 39, ); my $filename =''; #foreach $name (keys %planets) { # printf "%-8s %s\n", $name, $planets{$name}; #} foreach $filename (sort{(substr($a, -3) cmp substr($b,-3))||($a cmp $b)} keys %planets) { #printf "%-8s %s\n", $filename, $planets{$filename}; ($current_ext = $filename) =~ s/(.+\.)(\w{3})$/$2/; printf $current_ext."\n"; #printf $filename."\n"; }
run
|
edit
|
history
|
help
0
testing dereference of anonymous routines
Perl
Hash Refrence for memory optimization
FOP utilities
Price_supriya
Riyali-101738
main_objetos
objetos
test321
exam ata