Thread Zeilen der Größe nach Ausgeben
(10 answers)
Opened by RhoenSprudel at 2015-03-20 18:00
Vorschlag:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #!/usr/bin/perl use warnings; use strict; sub getIPasNumber { my $l = shift; chomp($l); my @a = split(" ", $l); my $n = $a[2]; $n =~ s/\.//g; return $n; } my @a = ("Server 1 111.222.333.444", "Server 2 222.333.444.555", "Server 3 111.333.444.555"); my %h; my $i; foreach $i (@a) { my $num = getIPasNumber($i); $h{$num} = $i; } foreach $i (sort {$b <=> $a} (keys(%h))) { print "$h{$i}\n"; } |