my $cache = "/proc/net/rt_cache";
my @fields;
open(CACHE, $cache) or die "Can't open $cache: $!";
while (<CACHE>) {
@fields = split;
next if $fields[1] eq $fields[2]; # Destination = Gateway
# Quick & dirty hack: just translate anything looking like a 32 bit hex
# number into dotted decimal notation (reverse byte order).
s/\b[0-9A-F]{8}\b/
sprintf "%d.%d.%d.%d", reverse unpack "C4", pack "H8", $& /eg;
# Only print the first 9 columns (up to & including MTU):
/(\S+\s+){8}\S+/ and print $& . "\n";
}