#!/usr/bin/env perl use strict; use warnings; =head1 DESCRIPTION Look for \cite commands that are not preceeded by a \citea command. This means that there is no text cite before a numbered cite. =cut my %seen; my %output; while (<<>>) { next if m/^\s*%/; while (m/\\(?citea?)\{(?.*?)\}/g) { my $keys = $+{keys}; my $cmd = $+{cmd}; for my $key (split /,/, $keys) { $key = trim($key); $seen{$key}++ if $cmd eq "citea"; print "incorrect order: $cmd - $key\n" if !defined $seen{$key} and $output{$key}++==0; } } } sub trim { my $str = shift; $str =~ s/\s*$//; $str =~ s/^\s*//; return $str; }