![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl Hash | Harikrishna | Shell Programming and Scripting | 1 | 06-03-2008 12:45 AM |
| Hash in perl | Harikrishna | Shell Programming and Scripting | 1 | 06-02-2008 05:00 AM |
| Urgent Help: Perl Hash compare | jamie123 | Shell Programming and Scripting | 10 | 01-04-2008 03:09 AM |
| Compare two arrays in sh or compare two fields | rijeshpp | Shell Programming and Scripting | 0 | 10-31-2007 02:47 AM |
| Hash within array, within hash, within array... | jsmoriss | Shell Programming and Scripting | 1 | 07-10-2006 10:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Code:
#!/usr/bin/perl
%arr = (
"maths" => 80,
"chemistry" => 100,
"physics" => 90 );
foreach $str (sort by_count keys %arr) {
print "$str - $arr{$str}\n";
}
sub by_count {
$b cmp $a;
}
or in short Code:
#!/usr/bin/perl
%arr = (
"maths" => 80,
"chemistry" => 100,
"physics" => 90 );
foreach $str (sort {$b cmp $a} %arr) {
print "$str - $arr{$str}\n";
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|