From ce20c31f182423630b5b71d59699708f0e8f536b Mon Sep 17 00:00:00 2001 From: Steven Wilson Date: Sat, 5 Oct 2019 15:29:27 +0100 Subject: [PATCH 1/3] use 3-argument open with promptfile --- bin/addbib | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/addbib b/bin/addbib index cc1db687..d8b99716 100644 --- a/bin/addbib +++ b/bin/addbib @@ -35,13 +35,13 @@ 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; From ea366140ce9407d2b6af791fea6457f37ee5de4e Mon Sep 17 00:00:00 2001 From: Steven Wilson Date: Sat, 5 Oct 2019 15:51:43 +0100 Subject: [PATCH 2/3] use 3-argument open with database --- bin/addbib | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/addbib b/bin/addbib index d8b99716..9b0d9810 100644 --- a/bin/addbib +++ b/bin/addbib @@ -45,7 +45,7 @@ if ($opt_p) { } 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 +71,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 +82,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__ From b4ce39873b4cdc045e58f0c8c2734fd6c23127a9 Mon Sep 17 00:00:00 2001 From: Steven Wilson Date: Sun, 6 Oct 2019 10:43:05 +0100 Subject: [PATCH 3/3] add use warnings --- bin/addbib | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/addbib b/bin/addbib index 9b0d9810..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);