in reply to divide by '/'
#!/usr/bin/perl -w # slurped file in @numbers # final outcome in %numHash @numbers = ( "432/205", "905/4578", "623/4568", "1/10009", "10/10005" +); foreach ( @numbers ) { ($key, $value) = split /\//, $_; $numHash{$key} = $value; } # UPDATED foreach $numerator ( sort { $a <=> $b } keys %numHash ) { print $numerator , '/' , $numHash{$numerator} , "\n"; }
TIMTOWTDI
Dex
p.s. - mine won't handle leading zeros, but the pizza man is en route!
UPDATE 0: - forgot my <=>!!!!! Need fud!
UPDATE 1: - check out how do i sort hash by key numerically
|
|---|