Skip to content

Instantly share code, notes, and snippets.

@mattfenwick
Created May 14, 2014 18:03
Show Gist options
  • Save mattfenwick/863e000ae013c277d259 to your computer and use it in GitHub Desktop.
Save mattfenwick/863e000ae013c277d259 to your computer and use it in GitHub Desktop.
examples
use strict;
use warnings;
local $/; # set slurp mode so that entire file is read at once (instead of a single line)
my $content = <STDIN>;
my %refs = ();
foreach my $key ($content =~ m/\\ref\{([\w_]+)\}/g) {
$refs{$key} = 1;
}
my %labels = ();
foreach my $key ($content =~ m/\\label\{([\w_]+)\}/g) {
$labels{$key} = 1;
}
foreach my $ref (keys %refs) {
if (!$labels{$ref}) {
print "oops, dangling ref: $ref\n";
}
}
foreach my $label (keys %labels) {
if (!$refs{$label}) {
print "oops, dangling label: $label\n";
}
}
print "\n";
#!/bin/bash
echo $@ # all args passed in
for name in $@
do
echo $name
cat $name | perl checkref.pl
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment