diff --git a/bin/addbib b/bin/addbib index cc1db687..c7e28488 100644 --- a/bin/addbib +++ b/bin/addbib @@ -13,6 +13,7 @@ License: use strict; +use warnings; use Getopt::Std; use vars qw($opt_a $opt_p); @@ -35,17 +36,17 @@ my @prompts = ( if ($opt_p) { @prompts = (); - open PROMPTFILE, $opt_p or die "can't read $opt_p: $!"; - foreach () { + open my $PROMPTFILE, '<', $opt_p or die "can't read $opt_p: $!"; + foreach (<$PROMPTFILE>) { if (/^\s*([^%]+)\t(%\w)/) { push @prompts, "$1\t$2"; } } - close(PROMPTFILE); + close($PROMPTFILE); } my $database = shift; -open DATABASE, ">>$database" or die "can't append to $database: $!"; +open my $DATABASE, '>>', $database or die "can't append to $database: $!"; my $inst = <<_EOINST; Addbib will prompt you for various bibliographic fields. @@ -71,7 +72,7 @@ print "$inst" if /^y/i; # I did it to preserve order. while (1) { - print DATABASE "\n"; # start a new entry + print $DATABASE "\n"; # start a new entry PROMPT: for (my $i=0; $i < @prompts; $i++) { my ($prompt, $code) = split /\t/, $prompts[$i]; @@ -82,40 +83,40 @@ while (1) { $i -= 2; next PROMPT; } - print DATABASE "$code\t"; + print $DATABASE "$code\t"; while (/\\$/) { chop; chop; - print DATABASE "$_\n"; + print $DATABASE "$_\n"; print "> "; $_ = <>; } - print DATABASE $_; + print $DATABASE $_; } unless ($opt_a) { print "Abstract: "; $_ = <>; next if (/^$/); - print DATABASE "%X\t$_"; + print $DATABASE "%X\t$_"; while (<>) { - print DATABASE $_; + print $DATABASE $_; } } } continue { print "Continue? (y) "; $_ = <>; while (/^\s*(edit|ex|vi|view|emacs)\s*/) { - close DATABASE or die "can't close $database: $!"; + close $DATABASE or die "can't close $database: $!"; system("$1 $database") == 0 or die "system '$1 $database' failed: $?"; - open DATABASE, ">>$database" or die "can't open $database: $!"; + open my $DATABASE, '>>', $database or die "can't open $database: $!"; print "Continue? (y) "; $_ = <>; } last if /^(n|q)/i; } -close DATABASE or die "can't close $database: $!"; +close $DATABASE or die "can't close $database: $!"; __END__