Wikipedia:Footnote3/numlink2note.pl

$ref=0; @urls=; while ( <> ) { while ( ($before,$url,$after) = m/(^|.*?[^[])\[([a-z][a-z0-9]+:[^][ ]+)\](.*)/i ) { $ref++; print $before, ""; $_ = $after; push @urls, $url; };   print $_; }

print "\n\n==Notes==\n\n"; print "\n";

$endnote=0; foreach (@urls) { $endnote++; print "# $_\n"; }

print STDERR "printed $ref references and $endnote endnotes .. should be the same\n";