sub sort_and_store { my @links = get_links(); my @sorted_links = sort { $a->[1] cmp $b->[1] } @links; open(my $fh, ">", "sorted.by.destination") or die "cannot open > sorted.by.destination: $!"; foreach my $tuple (@sorted_links) { print $fh "@$tuple\n"; } }