#!/usr/bin/perl # # bibfind -- Prints entries in your bib file that match search string. # # USAGE: bibfind [] # # Note: # Place bibfind in ~/bin, then chmod +x bibfind, then edit bibfind to change # the default bib file (see the variable $bibfile on line 29). # # 2001-07-05, Oyvind.Breivik@dnmi.no # ### Arguments my ($str,$file) = @ARGV; ### Locals my @paragraphs; my $home; my $bibfile; ### Main die "USAGE: $0 []\n" if $#ARGV < 0; $/ = ''; # $INPUT_RECORD_SEPARATOR set to read paragraphs $home = $ENV{"HOME"}; $bibfile = "$home/dok/tex/bibtex/Breivik.bib"; # Default bibtex file $file = $bibfile if ($#ARGV < 1); open(FILE, $file) or die "ERROR: Can't open $file"; print "$file\n"; @paragraphs = ; # Slurp up file by paragraph foreach (@paragraphs) { print if /$str/i; # Case ignored, if wanted, remove trailing i. }