Bundle-PBib
view release on metacpan or search on metacpan
lib/Biblio/bp/lib/bp-auto.pl view on Meta::CPAN
#
# bibliography package for Perl
#
# Auto format recognizer routines.
#
# Note that this package is intimately tied to the internals of the main
# package. Most format packages will _not_ look like this one. Since this
# does automatic recognition, it needs to change what the main package
# thinks the format of the file is.
#
# The basic idea is that we define open and openwrite, which they call on
# some file. We then determine the real format of the file (either by name,
# or by slogging through it trying to guess at the type <not implemented yet>)
# and then change the main package's pointers for this file to point to the
# real type. So we shouldn't ever be called again for that file.
#
# Dana Jacobsen (dana@acm.org)
# 14 January 1995 (last modified on 21 Jan 1996)
#
package bp_auto;
######
&bib'reg_format(
'auto', # name
'aut', # short name
'bp_auto', # package name
'auto', # default character set
'suffix is bib', # <--- This must match the default format.
# functions
'options',
'open',
'close is unsupported',
'read is unsupported',
'write is unsupported',
'explode is unsupported',
'implode is unsupported',
'tocanon is unsupported',
'fromcanon is unsupported',
'clear',
);
######
$opt_complex = 1;
$opt_default_format = 'bibtex';
######
sub options {
local($opts) = @_;
print "setting options to $opts\n";
}
######
sub autoformat {
local($file) = @_;
local($fmt) = undef;
return $opt_default_format if $opt_complex == 0;
if ($opt_complex == 1) {
# XXXXX We should use the i_suffix fields from each format for this.
# But... that would mean loading in _every_ format just so we
# can check these out. That's too painful.
$file =~ /\.bib$/ && return 'bibtex';
$file =~ /\.ref$/ && return 'refer';
$file =~ /\.tib$/ && return 'tib';
$file =~ /\.pow$/ && return 'powells';
$file =~ /\.pro$/ && return 'procite';
( run in 2.163 seconds using v1.01-cache-2.11-cpan-2398b32b56e )