#!/usr/bin/perl

($auxfile,$bibfile)=@ARGV;
open(AUX,$auxfile);
open(BIB,$bibfile);

while (<BIB>) {
   chomp;
   $key=$1 if /^@.*\{(.*),/;
   $crossref{$key}=$1 if /^\s*crossref\s*=\s*["{](.*)["}]/;
}
close(BIB);

while (<AUX>) {
   $nocite{$crossref{$1}}=1 if /\\citation\{(.*)\}/;
}
close(AUX);

foreach (sort keys %nocite) {
   print "\\nocite{$_}\n" if $_ ne '';
}
