#!/usr/local/bin/perl -w
use Getopt::Std;

sub find { shift }
my $dir = $0;
$dir =~ s#/\w+$#/#;
eval {require "$dir/utils.pm";};

my %opt;
getopts('q', \%opt);

open (WORDS, find('funcs.txt')) or die "Can't open funcs.txt, aborting";
my @words = ("NONE");

while (<WORDS>) {
  chomp;
  s/\s+.*$//;
  push @words, $_;
}

if (@ARGV and $ARGV[0] > 0) {
  foreach my $wordnum (@ARGV) {
    if ($opt{q}) {
      print $words[$wordnum], "\n";
    } else {
      printf "%5d %s\n", $wordnum, $words[$wordnum];
    }
  }
} else {
  while (<>) {
    #printf "%5d %s\n", $_, $words[$_];
    print, next if /^\s*\#/;
    chomp;
    if ($opt{q}) {
      print $words[$_], "\n";
    } else {
      printf "%s %s\n", $_, $words[$_];
    }
  }
}
