summaryrefslogtreecommitdiff
path: root/biblio/bibtex/utils/xbibfile/searchrefs.pl
blob: 72d2417ab0ecd25c6d735c7ed1914c0442633bd4 (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
39
40
41
42
43
44
45
46
47
#!/usr/bin/perl
#
# Script to print the key, the reference type, and the first part of the
#  title of ALL references in n BiBTeX database matching a given search
#  string.
#
#
#  This script is part of the XBibFile software package.
#  Writer:  Ross Maloney
#  Date:    August 2000
#

$count = 0;
while ( <> ) {
    chomp;
    if ( /@/ )  {
      $type = 'x';
      $ptr_flag = 0;
      $note_flag = 0;
      if ( /\@ARTICLE/ ) {  $type = 'A' } ;
      if ( /\@BOOK/ ) {  $type = 'B' } ;
      if ( /\@INCOLLECTION/ ) {  $type = 'C' } ;
      if ( /\@INPROCEEDINGS/ ) {  $type = 'P' } ;
      if ( /\@PHDTHESIS/ ) {  $type = 'T' } ;
      @reftype = split(/{/, $_);
      $reftype[1] =~ s/,//;
    }
    elsif ( /^ +title = \{/ ) {
      @fields = split(/{/, $_);
      $fields[1] =~ s/},//;
    }
    elsif ( /^ +annote = \{/ )  {
      $note_flag = 1;
    }
    if ( $note_flag )  {
	if ( /poem/i ) {            # check for test string being present
	    if ( $ptr_flag == 0 )  {
               $count++ ;
               printf "\n%s  %s", $type, $reftype[1];
               printf "\t%s", substr($fields[1], 0, 50) ;
               $ptr_flag = 1;
	   }
            printf "\n*  %s", $_;
        }
    } 
}
print "\nnumber of references = $count\n" ;