From 75a80b449ca03a2f04af173ed99d5cd679205bd0 Mon Sep 17 00:00:00 2001 From: Nicolas R Date: Thu, 17 Nov 2022 16:06:59 -0700 Subject: [PATCH] Use three args open Fix #113 Prefer using three args open over the two args form. --- &1 | 0 adm/cvskwexp | 2 +- adm/mkppm | 8 ++++---- adm/release-graph | 2 +- adm/sourceforge/updindex | 4 ++-- adm/urlchk | 2 +- lib/Log/Log4perl/Appender/File.pm | 4 ++-- lib/Log/Log4perl/FAQ.pm | 6 +++--- lib/Log/Log4perl/InternalDebug.pm | 2 +- lib/Log/Log4perl/Resurrector.pm | 2 +- t/004Config.t | 12 ++++++------ t/005Config-Perl.t | 2 +- t/006Config-Java.t | 2 +- t/007LogPrio.t | 2 +- t/010JConsole.t | 8 ++++---- t/017Watch.t | 8 ++++---- t/018Init.t | 2 +- t/019Warn.t | 4 ++-- t/020Easy.t | 16 ++++++++-------- t/025CustLevels.t | 10 +++++----- t/026FileApp.t | 32 +++++++++++++++---------------- t/027Watch2.t | 6 +++--- t/027Watch3.t | 4 ++-- t/042SyncApp.t | 14 +++++++------- t/048lwp.t | 6 +++--- t/051Extra.t | 4 ++-- t/052Utf8.t | 4 ++-- t/062InitHash.t | 2 +- 28 files changed, 85 insertions(+), 85 deletions(-) create mode 100644 &1 diff --git a/&1 b/&1 new file mode 100644 index 00000000..e69de29b diff --git a/adm/cvskwexp b/adm/cvskwexp index 1a019978..a4625cb2 100755 --- a/adm/cvskwexp +++ b/adm/cvskwexp @@ -12,7 +12,7 @@ find(sub { return if /cvskwexp/; my $file = $_; # print "Examining $_\n"; - open FILE, "<$_" or die "Cannot open $_"; + open FILE, '<', "$_" or die "Cannot open $_"; while() { die "$file: $_" if /\$\s*Log.*\$/; } diff --git a/adm/mkppm b/adm/mkppm index 76c5c9ab..2ef741cf 100755 --- a/adm/mkppm +++ b/adm/mkppm @@ -98,12 +98,12 @@ sub fix_ppd { ########################################### my($ppd_file) = @_; - open FILE, "<$ppd_file" or die "Cannot open $ppd_file"; + open FILE, '<', "$ppd_file" or die "Cannot open $ppd_file"; my $data = join '', ; $data =~ s/-\d+\.\d+//g; close FILE; - open FILE, ">$ppd_file" or die "Cannot open $ppd_file"; + open FILE, '>', "$ppd_file" or die "Cannot open $ppd_file"; print FILE $data; close FILE; } @@ -114,7 +114,7 @@ sub patch_log_dispatch { # Get rid of Log::Dispatch's annoying user prompting - open FILE, "; close FILE; @@ -124,7 +124,7 @@ sub patch_log_dispatch { /; $data =~ s/while\s*\(\s*1\s*\)/while(0)/; - open FILE, ">Makefile.PL" or die "Cannot open Makefile.PL (w)"; + open FILE, '>', "Makefile.PL" or die "Cannot open Makefile.PL (w)"; print FILE $data; close FILE; } diff --git a/adm/release-graph b/adm/release-graph index e8c33b76..7e8c7bfa 100755 --- a/adm/release-graph +++ b/adm/release-graph @@ -16,7 +16,7 @@ my($y, $m, $d); my $last_time = undef; -open FILE, ") { chomp; diff --git a/adm/sourceforge/updindex b/adm/sourceforge/updindex index 7b80fdf8..067dfb03 100755 --- a/adm/sourceforge/updindex +++ b/adm/sourceforge/updindex @@ -10,7 +10,7 @@ die "usage: $0 version" unless $version =~ /^[\d.]+\w+$/; system "git checkout gh-pages" and die $!; -open FILE, "<$IDX" or die "Cannot open $IDX"; +open FILE, "<", "$IDX" or die "Cannot open $IDX"; my $data = join '', ; close FILE; @@ -26,7 +26,7 @@ if(defined $devprod and $devprod =~ /(dev)|(alpha)|(beta)/) { $data =~ s@.*?@\n@s; } -open FILE, ">$IDX" or die "Cannot open $IDX"; +open FILE, ">", "$IDX" or die "Cannot open $IDX"; print FILE $data; close FILE; diff --git a/adm/urlchk b/adm/urlchk index acbaaa46..c01f9697 100755 --- a/adm/urlchk +++ b/adm/urlchk @@ -16,7 +16,7 @@ for(File::Find::Rule->file()->in(".")) { next if m#\./blib/#; - open FILE, "<$_" or die "Cannot open $_"; + open FILE, "<", "$_" or die "Cannot open $_"; my $data = join '', ; close FILE; diff --git a/lib/Log/Log4perl/Appender/File.pm b/lib/Log/Log4perl/Appender/File.pm index 9960817f..d9f471e9 100755 --- a/lib/Log/Log4perl/Appender/File.pm +++ b/lib/Log/Log4perl/Appender/File.pm @@ -57,7 +57,7 @@ sub new { if($self->{recreate_pid_write}) { print "Creating pid file", " $self->{recreate_pid_write}\n" if _INTERNAL_DEBUG; - open FILE, ">$self->{recreate_pid_write}" or + open FILE, ">", "$self->{recreate_pid_write}" or die "Cannot open $self->{recreate_pid_write}"; print FILE "$$\n"; close FILE; @@ -148,7 +148,7 @@ sub file_open { sysopen $fh, "$self->{filename}", $sysmode or die "Can't sysopen $self->{filename} ($!)"; } else { - open $fh, "$arrows$self->{filename}" or + open $fh, $arrows, "$self->{filename}" or die "Can't open $self->{filename} ($!)"; } }; diff --git a/lib/Log/Log4perl/FAQ.pm b/lib/Log/Log4perl/FAQ.pm index c0c068bf..a72cc17f 100644 --- a/lib/Log/Log4perl/FAQ.pm +++ b/lib/Log/Log4perl/FAQ.pm @@ -304,12 +304,12 @@ for details. Have fun! Whenever you encounter a fatal error in your application, instead of saying something like - open FILE, "logdie("Can't open blah -- bailing out!"); + open FILE, "<", "blah" or $log->logdie("Can't open blah -- bailing out!"); This will both log the message with priority FATAL according to your current Log::Log4perl configuration and then call Perl's C @@ -318,7 +318,7 @@ stealth loggers (see L), all you need to do is call use Log::Log4perl qw(:easy); - open FILE, " internally if something goes wrong? Use a diff --git a/lib/Log/Log4perl/InternalDebug.pm b/lib/Log/Log4perl/InternalDebug.pm index 2cee7d0b..976d0f4b 100644 --- a/lib/Log/Log4perl/InternalDebug.pm +++ b/lib/Log/Log4perl/InternalDebug.pm @@ -19,7 +19,7 @@ sub internal_debug_fh { my($file) = @_; local($/) = undef; - open FILE, "<$file" or die "Cannot open $file"; + open FILE, "<", "$file" or die "Cannot open $file"; my $text = ; close FILE; diff --git a/lib/Log/Log4perl/Resurrector.pm b/lib/Log/Log4perl/Resurrector.pm index 0eee01ab..972d76c4 100644 --- a/lib/Log/Log4perl/Resurrector.pm +++ b/lib/Log/Log4perl/Resurrector.pm @@ -24,7 +24,7 @@ sub resurrector_fh { my($file) = @_; local($/) = undef; - open FILE, "<$file" or die "Cannot open $file"; + open FILE, "<", "$file" or die "Cannot open $file"; my $text = ; close FILE; diff --git a/t/004Config.t b/t/004Config.t index c064acc6..16cdba82 100644 --- a/t/004Config.t +++ b/t/004Config.t @@ -203,8 +203,8 @@ is(Log::Log4perl::Appender::TestBuffer->by_name("A1")->buffer(), ###################################################################### # Test integrity check ###################################################################### -open STDERR, ">$TMP_FILE"; -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; sub readwarn { return (scalar ) || ''; } END { close IN } @@ -222,8 +222,8 @@ unlink $TMP_FILE; ###################################################################### # Misspelled 'rootlogger' (needs to be rootLogger) ###################################################################### -open STDERR, ">$TMP_FILE"; -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; Log::Log4perl->reset(); $Log::Log4perl::Logger::LOGGERS_BY_NAME = {}; @@ -245,8 +245,8 @@ unlink $TMP_FILE; ###################################################################### # Totally misspelled rootLogger ###################################################################### -open STDERR, ">$TMP_FILE"; -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; Log::Log4perl->reset(); $Log::Log4perl::Logger::LOGGERS_BY_NAME = {}; diff --git a/t/005Config-Perl.t b/t/005Config-Perl.t index b3ec8168..7f9c5374 100644 --- a/t/005Config-Perl.t +++ b/t/005Config-Perl.t @@ -29,7 +29,7 @@ my $logger = Log::Log4perl->get_logger(""); my $line = __LINE__ + 1; $logger->debug("Gurgel"); -open LOG, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open LOG, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; my $data = ; END { close LOG; unlink $LOGFILE; } diff --git a/t/006Config-Java.t b/t/006Config-Java.t index d2dc87ec..ad20a56f 100644 --- a/t/006Config-Java.t +++ b/t/006Config-Java.t @@ -50,7 +50,7 @@ push @lines, $line++; $logger->warn("Gurgel"); push @lines, $line++; $logger->error("Gurgel"); push @lines, $line++; $logger->fatal("Gurgel"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; my $data = join '', ; close FILE; diff --git a/t/007LogPrio.t b/t/007LogPrio.t index eac5aa44..6957ef84 100644 --- a/t/007LogPrio.t +++ b/t/007LogPrio.t @@ -43,7 +43,7 @@ push @lines, $line++; $logger->warn("Gurgel"); push @lines, $line++; $logger->error("Gurgel"); push @lines, $line++; $logger->fatal("Gurgel"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; my $data = join '', ; close FILE; diff --git a/t/010JConsole.t b/t/010JConsole.t index c7596809..c2d493f5 100644 --- a/t/010JConsole.t +++ b/t/010JConsole.t @@ -42,10 +42,10 @@ Log::Log4perl->init(\$conf); my $logger = Log::Log4perl->get_logger('cat1'); #hmm, I wonder how portable this is, maybe check $^O first? -open(OLDOUT, ">&STDOUT"); -open (TOUCH, ">>$test_logfile");# `touch $test_logfile`; +open(OLDOUT, ">&", STDOUT) or die; +open (TOUCH, ">>", $test_logfile);# `touch $test_logfile`; close TOUCH; -open(STDOUT, ">$test_logfile") || die "Can't redirect stdout $test_logfile $!"; +open(STDOUT, ">", $test_logfile) or die "Can't redirect stdout $test_logfile $!"; select(STDOUT); $| = 1; # make unbuffered $logger->debug("debugging message 1 "); @@ -54,7 +54,7 @@ $logger->warn("warning message 1 "); $logger->fatal("fatal message 1 "); close(STDOUT); -open(STDOUT, ">&OLDOUT"); +open(STDOUT, ">&", OLDOUT); my ($result, $expected); diff --git a/t/017Watch.t b/t/017Watch.t index 8f8cc84c..8ab45096 100644 --- a/t/017Watch.t +++ b/t/017Watch.t @@ -17,7 +17,7 @@ use Log::Log4perl; use File::Spec; sub trunc { - open FILE, ">$_[0]" or die "Cannot open $_[0]"; + open FILE, ">", "$_[0]" or die "Cannot open $_[0]"; close FILE; } @@ -35,7 +35,7 @@ log4j.appender.myAppender.filename = $testfile log4j.appender.myAppender.mode = append EOL -open (CONF, ">$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf1; close CONF; @@ -83,7 +83,7 @@ log4j.appender.myAppender.filename = $testfile log4j.appender.myAppender.mode = append EOL -open (CONF, ">$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf2; close CONF; @@ -129,7 +129,7 @@ log4j.appender.myAppender.layout = Log::Log4perl::Layout::SimpleLayout log4j.appender.myAppender.filename = $testfile log4j.appender.myAppender.mode = append EOL -open (CONF, ">$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf2; close CONF; diff --git a/t/018Init.t b/t/018Init.t index 897a4db2..218e6572 100644 --- a/t/018Init.t +++ b/t/018Init.t @@ -48,7 +48,7 @@ $log->info("Shu-wa-chi!"); # Check if both files contain one message each for my $file ($testfilea, $testfileb) { - open FILE, "<$file" or die "Cannot open $file"; + open FILE, "<", "$file" or die "Cannot open $file"; my $content = join '', ; close FILE; ok($content, "INFO - Shu-wa-chi!\n"); diff --git a/t/019Warn.t b/t/019Warn.t index 7495a288..17843476 100644 --- a/t/019Warn.t +++ b/t/019Warn.t @@ -21,8 +21,8 @@ my $TMP_FILE = File::Spec->catfile($WORK_DIR, qw(warnings)); ok(1); # Initialized ok # Capture STDERR to a temporary file and a filehandle to read from it -open STDERR, ">$TMP_FILE"; -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; sub readwarn { return scalar ; } ############################################################ diff --git a/t/020Easy.t b/t/020Easy.t index a6fea298..75f2e414 100644 --- a/t/020Easy.t +++ b/t/020Easy.t @@ -40,9 +40,9 @@ ok(1); # Initialized ok unlink $TMP_FILE; # Capture STDOUT to a temporary file and a filehandle to read from it -open STDERR, ">$TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; select STDERR; $| = 1; #needed on win32 -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; sub readstderr { IN->clearerr(); return join("", ); } ############################################################ @@ -66,7 +66,7 @@ like($stderr, qr/this also/); Log::Log4perl->reset(); close IN; # Reopen stderr -open STDERR, ">&1"; +open STDERR, ">", "&1"; unlink $TMP_FILE; package Bar::Twix; @@ -97,7 +97,7 @@ Log::Log4perl->easy_init( Bar::Mars::crunch(); Bar::Twix::crunch(); -open FILE, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open FILE, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; my $data = join '', ; close FILE; @@ -107,9 +107,9 @@ is($data, "020Easy.t-$line-Bar::Mars::crunch: Mars mjam\nTwix mjam\n"); # LOGDIE and LOGWARN ############################################################ # redir STDERR again -open STDERR, ">$TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; select STDERR; $| = 1; #needed on win32 -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; Log::Log4perl->easy_init($INFO); $log = get_logger(); @@ -172,9 +172,9 @@ close IN; # LOGCARP and LOGCROAK ############################################################ # redir STDERR again -open STDERR, ">$TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; select STDERR; $| = 1; #needed on win32 -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; package Whack; use Log::Log4perl qw(:easy); diff --git a/t/025CustLevels.t b/t/025CustLevels.t index f16b96bb..3b03f0fe 100644 --- a/t/025CustLevels.t +++ b/t/025CustLevels.t @@ -99,7 +99,7 @@ $logger->litewarn("this is a LITE warning message (2/3 the calories)"); $logger->info("this info message should not log"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; $/ = undef; my $data = ; close FILE; @@ -113,7 +113,7 @@ $logger->warn("this is a rootlevel warning message"); $logger->litewarn("this is a rootlevel LITE warning message (2/3 the calories)"); $logger->info("this rootlevel info message should not log"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; $/ = undef; $data = ; close FILE; @@ -124,7 +124,7 @@ $logger->log($WARN, "a warning message"); $logger->log(Log::Log4perl::Level::to_priority("LITEWARN"), "a LITE warning message"); $logger->log($DEBUG, "an info message, should not log"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; $/ = undef; $data = ; close FILE; @@ -136,7 +136,7 @@ ok($data, "$result1$result2$result3"); my $debug2 = Log::Log4perl->get_logger("debug2test"); $debug2->debug2("this is a debug2 message"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; $/ = undef; $data = ; close FILE; @@ -161,7 +161,7 @@ ok(!$logger->is_litewarn); ok(!$logger->is_info); $logger->warn("after bumping, warning message"); $logger->litewarn("after bumping, lite warning message, should not log"); -open FILE, "<$LOGFILE" or die "Cannot open $LOGFILE"; +open FILE, "<", "$LOGFILE" or die "Cannot open $LOGFILE"; $/ = undef; $data = ; close FILE; diff --git a/t/026FileApp.t b/t/026FileApp.t index c9a35bf9..e8eaadad 100644 --- a/t/026FileApp.t +++ b/t/026FileApp.t @@ -32,7 +32,7 @@ my $testpath = File::Spec->catdir($WORK_DIR, "test26"); #################################################### # First, preset the log file with some content #################################################### -open FILE, ">$testfile" or die "Cannot create $testfile"; +open FILE, ">", "$testfile" or die "Cannot create $testfile"; print FILE "previous content\n"; close FILE; @@ -51,7 +51,7 @@ Log::Log4perl::init(\$data); my $log = Log::Log4perl::get_logger(""); $log->info("Shu-wa-chi!"); -open FILE, "<$testfile" or die "Cannot create $testfile"; +open FILE, "<", "$testfile" or die "Cannot create $testfile"; my $content = join '', ; close FILE; @@ -72,7 +72,7 @@ Log::Log4perl::init(\$data); $log = Log::Log4perl::get_logger(""); $log->info("Shu-wa-chi!"); -open FILE, "<$testfile" or die "Cannot create $testfile"; +open FILE, "<", "$testfile" or die "Cannot create $testfile"; $content = join '', ; close FILE; @@ -93,7 +93,7 @@ Log::Log4perl::init(\$data); $log = Log::Log4perl::get_logger(""); $log->info("Shu-wa-chi!"); -open FILE, "<$testfile" or die "Cannot create $testfile"; +open FILE, "<", "$testfile" or die "Cannot create $testfile"; $content = join '', ; close FILE; @@ -123,7 +123,7 @@ $log = Log::Log4perl::get_logger(""); $log->info("Shu-wa-chi!"); for(qw(1 2)) { - open FILE, "<${testfile}_$_" or die "Cannot open ${testfile}_$_"; + open FILE, "<", "${testfile}_$_" or die "Cannot open ${testfile}_$_"; $content = join '', ; close FILE; @@ -154,7 +154,7 @@ $log = Log::Log4perl::get_logger(""); $log->info("Shu-wa-chi!"); for(qw(1 2)) { - open FILE, "<${testfile}_$_" or die "Cannot open ${testfile}_$_"; + open FILE, "<", "${testfile}_$_" or die "Cannot open ${testfile}_$_"; $content = join '', ; close FILE; @@ -181,7 +181,7 @@ $app->file_switch("${testfile}_2"); $log->info("File2"); for(qw(1 2)) { - open FILE, "<${testfile}_$_" or die "Cannot open ${testfile}_$_"; + open FILE, "<", "${testfile}_$_" or die "Cannot open ${testfile}_$_"; $content = join '', ; close FILE; @@ -206,7 +206,7 @@ Log::Log4perl::init(\$data); $log = Log::Log4perl::get_logger(""); $log->info("File1"); -open FILE, "<${testfile}_1" or die "Cannot open ${testfile}_1"; +open FILE, "<", "${testfile}_1" or die "Cannot open ${testfile}_1"; $content = join '', ; close FILE; @@ -215,7 +215,7 @@ is($content, "INFO - File1\n"); Log::Log4perl::init(\$data); $log->info("File1"); -open FILE, "<${testfile}_1" or die "Cannot open ${testfile}_1"; +open FILE, "<", "${testfile}_1" or die "Cannot open ${testfile}_1"; $content = join '', ; close FILE; @@ -237,7 +237,7 @@ Log::Log4perl::init(\$data); $log = Log::Log4perl::get_logger(""); $log->info("File1"); -open FILE, "<${testfile}_1" or die "Cannot open ${testfile}_1"; +open FILE, "<", "${testfile}_1" or die "Cannot open ${testfile}_1"; $content = join '', ; close FILE; @@ -267,7 +267,7 @@ unlink "${testfile}_1"; $log->info("File1-1"); -open FILE, "<${testfile}_1" or die "Cannot open ${testfile}_1"; +open FILE, "<", "${testfile}_1" or die "Cannot open ${testfile}_1"; $content = join '', ; close FILE; @@ -323,7 +323,7 @@ unlink "${testfile}_1"; is(kill('USR1', $$), 1, "sending signal"); $log->info("File1"); -open FILE, "<${testfile}_1" or die "Cannot open ${testfile}_1"; +open FILE, "<", "${testfile}_1" or die "Cannot open ${testfile}_1"; $content = join '', ; close FILE; @@ -349,7 +349,7 @@ ok(! -f "${testfile}_3"); $log = Log::Log4perl::get_logger(""); $log->info("File1"); -open FILE, "<${testfile}_3" or die "Cannot open ${testfile}_3"; +open FILE, "<", "${testfile}_3" or die "Cannot open ${testfile}_3"; $content = join '', ; close FILE; @@ -378,7 +378,7 @@ ok(! -f "${testfile}_4"); $log = Log::Log4perl::get_logger(""); $log->info("File1"); -open FILE, "<${testfile}_4" or die "Cannot open ${testfile}_4"; +open FILE, "<", "${testfile}_4" or die "Cannot open ${testfile}_4"; $content = join '', ; close FILE; @@ -398,7 +398,7 @@ log4perl.appender.Logfile.layout = Log::Log4perl::Layout::SimpleLayout ); Log::Log4perl->init(\$data); -open FILE, "<${testfile}_5" or die "Cannot open ${testfile}_5"; +open FILE, "<", "${testfile}_5" or die "Cannot open ${testfile}_5"; $content = join '', ; close FILE; @@ -442,7 +442,7 @@ Log::Log4perl::init(\$data); $log = Log::Log4perl::get_logger(""); $log->info("Shu-wa-chi!"); -open FILE, "<$testmkpathfile" or die "Cannot create $testmkpathfile"; +open FILE, "<", "$testmkpathfile" or die "Cannot create $testmkpathfile"; $content = join '', ; close FILE; diff --git a/t/027Watch2.t b/t/027Watch2.t index 713c67a7..3873aec6 100644 --- a/t/027Watch2.t +++ b/t/027Watch2.t @@ -38,7 +38,7 @@ log4j.appender.goneAppender.layout = Log::Log4perl::Layout::SimpleLayout log4j.category.animal.cat = INFO, myAppender EOL -open (CONF, ">$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf1; close CONF; @@ -79,7 +79,7 @@ log4j.appender.myAppender.layout = Log::Log4perl::Layout::SimpleLayout log4j.category.animal.cat = INFO, myAppender EOL -open (CONF, ">$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf1; close CONF; @@ -188,7 +188,7 @@ sub conf_file_write { $level = "DEBUG" unless defined $level; - open FILE, ">$testconf" or die $!; + open FILE, ">", "$testconf" or die $!; print FILE <$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf1; close CONF; @@ -80,7 +80,7 @@ log4j.appender.myAppender.layout = Log::Log4perl::Layout::SimpleLayout log4j.category.animal.cat = INFO, myAppender EOL -open (CONF, ">$testconf") || die "can't open $testconf $!"; +open (CONF, ">", "$testconf") || die "can't open $testconf $!"; print CONF $conf1; close CONF; diff --git a/t/042SyncApp.t b/t/042SyncApp.t index fe8479c4..27da59a1 100644 --- a/t/042SyncApp.t +++ b/t/042SyncApp.t @@ -99,7 +99,7 @@ print "Done waiting for pid $pid\n" if $INTERNAL_DEBUG; my $clashes_found = 0; -open FILE, "<$logfile" or die "Cannot open $logfile"; +open FILE, "<", "$logfile" or die "Cannot open $logfile"; while() { if(/XY/ || /YX/) { $clashes_found = 1; @@ -206,7 +206,7 @@ if($pid) { my $nof_messages = 2; - open FILE, ">$logfile" or die "Cannot open $logfile"; + open FILE, ">", "$logfile" or die "Cannot open $logfile"; while(my $client = $sock->accept()) { #print "Client connected\n"; while(<$client>) { @@ -225,7 +225,7 @@ print "Waiting for pid $pid\n" if $INTERNAL_DEBUG; waitpid($pid, 0); print "Done waiting for pid $pid\n" if $INTERNAL_DEBUG; -open FILE, "<$logfile" or die "Cannot open $logfile"; +open FILE, "<", "$logfile" or die "Cannot open $logfile"; my $data = join '', ; close FILE; @@ -243,8 +243,8 @@ our $TMP_FILE = "warnings.txt"; END { unlink $TMP_FILE if defined $TMP_FILE; } # Capture STDERR to a temporary file and a filehandle to read from it -open STDERR, ">$TMP_FILE"; -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; sub readwarn { return scalar ; } $conf = q{ @@ -301,7 +301,7 @@ if($pid) { my $nof_messages = 1; - open FILE, ">$logfile" or die "Cannot open $logfile"; + open FILE, ">", "$logfile" or die "Cannot open $logfile"; while(my $client = $sock->accept()) { #print "Client connected\n"; while(<$client>) { @@ -321,7 +321,7 @@ print "Waiting for pid $pid\n" if $INTERNAL_DEBUG; waitpid($pid, 0); print "Done waiting for pid $pid\n" if $INTERNAL_DEBUG; -open FILE, "<$logfile" or die "Cannot open $logfile"; +open FILE, "<", "$logfile" or die "Cannot open $logfile"; $data = join '', ; close FILE; diff --git a/t/048lwp.t b/t/048lwp.t index 7540f1f6..61763ecd 100644 --- a/t/048lwp.t +++ b/t/048lwp.t @@ -44,7 +44,7 @@ my $tmpfile = Log::Log4perl::Util::tmpfile_name(); END { unlink $tmpfile }; $ua->get("file:$tmpfile"); -open LOG, "); close LOG; @@ -67,7 +67,7 @@ Log::Log4perl->infiltrate_lwp(); $ua = LWP::UserAgent->new(); $ua->get("file:$tmpfile"); -open LOG, "); close LOG; @@ -89,7 +89,7 @@ Log::Log4perl->infiltrate_lwp(); $ua = LWP::UserAgent->new(); $ua->get("file:$tmpfile"); -open LOG, "); close LOG; diff --git a/t/051Extra.t b/t/051Extra.t index 96d1200a..ee1ff7c4 100644 --- a/t/051Extra.t +++ b/t/051Extra.t @@ -45,9 +45,9 @@ Log::Log4perl->init(\$conf); my $WORK_DIR = tmpdir(); my $TMP_FILE = File::Spec->catfile($WORK_DIR, qw(easy)); -open STDERR, ">$TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; select STDERR; $| = 1; #needed on win32 -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; binmode IN, ":utf8"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; binmode IN, ":utf8"; sub readstderr { IN->clearerr(); return join("", ); } END { unlink $TMP_FILE; diff --git a/t/052Utf8.t b/t/052Utf8.t index 119eb326..e8104301 100644 --- a/t/052Utf8.t +++ b/t/052Utf8.t @@ -85,10 +85,10 @@ like($data, qr/\x{30B8}/, "easy: utf8-1"); # Easy mode with utf8 setting ########### -open STDERR, ">$TMP_FILE"; +open STDERR, ">", "$TMP_FILE"; select STDERR; $| = 1; #needed on win32 select STDOUT; -open IN, "<$TMP_FILE" or die "Cannot open $TMP_FILE"; binmode IN, ":utf8"; +open IN, "<", "$TMP_FILE" or die "Cannot open $TMP_FILE"; binmode IN, ":utf8"; sub readstderr { return join("", ); } END { unlink $TMP_FILE; diff --git a/t/062InitHash.t b/t/062InitHash.t index 5783554f..9382a8c2 100644 --- a/t/062InitHash.t +++ b/t/062InitHash.t @@ -19,7 +19,7 @@ Log::Log4perl->init({ Log::Log4perl->get_logger->debug('yee haw'); -open FILE, "<$logfile" or die $!; +open FILE, "<", "$logfile" or die $!; my $data = join '', ; close FILE;