blob: f2ac1a3760e8f65a8ca0a37c868d08fb5b4e71a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/perl
#
# bibfind -- Prints entries in your bib file that match search string.
#
# USAGE: bibfind <string> [<file>]
#
# 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 <string> [<file>]\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 = <FILE>; # Slurp up file by paragraph
foreach (@paragraphs) {
print if /$str/i; # Case ignored, if wanted, remove trailing i.
}
|