Skip to content

Instantly share code, notes, and snippets.

@satyr
Created October 16, 2009 21:07
Show Gist options
  • Save satyr/212074 to your computer and use it in GitHub Desktop.
Save satyr/212074 to your computer and use it in GitHub Desktop.
ArcRef
#!perl
use strict;
use warnings;
use File::Basename;
unless(@ARGV){
print "usage: $0 {def/mac name}\n";
exit 1;
}
chdir dirname $0;
our $re = qr/\((?:x?def|mac|=)\s+$ARGV[0]\s+/;
for my $f ('ac.scm', glob '*.arc'){
exit if findref($f);
}
sub findref {
my $file = shift;
unless(open Arc, "< $file"){
warn "failed to open $file";
return 0;
}
while(<Arc>){
next unless $_ =~ $re;
print "$file\n";
print;
print while ($_ = <Arc>) =~ /^./;
return 1;
}
0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment