in reply to Sorting sub pains...
for my $source (sort traffic_combined keys %data) { print "$source data transfer out: $data{$source}{$all}.\n" +; my $traffic_machine = sub { $data{$source}{$b} <=> $data{$source}{$a} } for my $destination (sort $traffic_machine keys %{$data{$s +ource}}) { next if ($destination eq $all); print "$source -> $destination: $data{$source}{$destin +ation}.\n" +; } }
That way, we're making the inner sort into a closure, which will keep track of the current $source. sort checks its first argument to see if it's a sub or a closure, making this useful.
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|