#!/usr/local/bin/perl use warnings; use strict; use vars qw(%opts $author_rx $pubtype_rx %pubmap %titlemap); use Getopt::Std; sub usage { my $err = shift || ''; print $err, <DATA>; exit; } $opts{t} = '.*'; # default getopts('ha:d:t:', \%opts) or usage "Invalid Args.\n"; usage() if $opts{h}; usage "Missing Mandatory Args.\n" unless defined $opts{d} and defined +$opts{a}; $author_rx = qr/\Q$opts{a}/; $pubtype_rx = qr/$opts{t}/; open TITLES, "$opts{d}/titles.dbase" or die "couldn't open titles.dbas +e file"; open PUBS, "$opts{d}/pubs.dbase" or die "couldn't open pubs.dbase +file"; while (<TITLES>) { my $line = $_; chomp $line; # split ignores trailing empty fields unless you ask for # a specific number of fields (ignore trailing |) ... my @fields = split /\|/, $line, ($line =~ tr/|/|/); next unless $fields[1] =~ /$author_rx/; foreach my $pubcode (split /\,/, $fields[5]) { $pubmap{$pubcode} = [] unless exists $pubmap{$pubcode}; push @{$pubmap{$pubcode}}, $line; } } while (<PUBS>) { my $line = $_; chomp $line; # split ignores trailing empty fields unless you ask for # a specific number of fields (ignore trailing |) ... my @fields = split /\|/, $line, ($line =~ tr/|/|/); next unless exists $pubmap{$fields[0]}; next unless $fields[8] =~ /$pubtype_rx/; foreach my $titleline (@{$pubmap{$fields[0]}}) { my $title = (split /\|/, $titleline)[0]; $titlemap{$title} = [] unless exists $titlemap{$title}; push @{$titlemap{$title}}, "$title|$line$titleline\n"; } } foreach my $title (sort keys %titlemap) { foreach my $line (@{$titlemap{$title}}) { print $line; } } __END__ Usage: isfdb-list-author.pl -d dbase_compiled_dir -a auth_substr [-t pubty +pe_regex ] Examples: isfdb-list-author.pl -d ~/isfdb/dbase.compiled -a Asimov isfdb-list-author.pl -d ~/isfdb/dbase.compiled -a 'G. Harry Stine^L +ee Correy' isfdb-list-author.pl -d ~/isfdb/dbase.compiled -a Asimov -t 'hc|pb' isfdb-list-author.pl -d ~/isfdb/dbase.compiled -a Asimov -t '^$' Output: One record per title/pub combo that mathches the specified criteria +. The 1st field is the title, after that comes all of the fields about th +e publication, and then all of the fields about the title. In standa +rd ISFDB compiled DB format there is a trailing | after the last field.

In reply to ISFDB: Author Publication List by hossman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.