Преглед на файлове

perl: Surround FileHandles with braces in print calls

Fixes InputOutput::RequireBracedFileHandleWithPrint.

Warned-by: perlcritic
Guillem Jover преди 12 години
родител
ревизия
b2590e1ea1

+ 1 - 1
dselect/methods/Dselect/Ftp.pm

@@ -74,7 +74,7 @@ sub store_config {
 
   open(my $vars_fh, '>', $vars)
     or die "couldn't open $vars in write mode: $!\n";
-  print $vars_fh Dumper(\%CONFIG);
+  print { $vars_fh } Dumper(\%CONFIG);
   close $vars_fh;
 }
 

+ 1 - 1
dselect/methods/ftp/install

@@ -628,7 +628,7 @@ foreach (keys %md5sums) {
 }
 open(my $md5sums_fh, '>', "$methdir/md5sums")
   or die "can't open $methdir/md5sums in write mode: $!\n";
-print $md5sums_fh Dumper(\%md5sums);
+print { $md5sums_fh } Dumper(\%md5sums);
 close $md5sums_fh;
 
 exit $exit;

+ 1 - 1
scripts/Dpkg/BuildOptions.pm

@@ -166,7 +166,7 @@ sub output {
     my ($self, $fh) = @_;
     my $o = $self->{options};
     my $res = join(' ', map { defined($o->{$_}) ? $_ . '=' . $o->{$_} : $_ } sort keys %$o);
-    print $fh $res if defined $fh;
+    print { $fh } $res if defined $fh;
     return $res;
 }
 

+ 2 - 2
scripts/Dpkg/Changelog.pm

@@ -462,12 +462,12 @@ sub output {
     my $str = '';
     foreach my $entry (@{$self}) {
 	my $text = $entry->output();
-	print $fh $text if defined $fh;
+	print { $fh } $text if defined $fh;
 	$str .= $text if defined wantarray;
     }
     my $text = $self->get_unparsed_tail();
     if (defined $text) {
-	print $fh $text if defined $fh;
+	print { $fh } $text if defined $fh;
 	$str .= $text if defined wantarray;
     }
     return $str;

+ 1 - 1
scripts/Dpkg/Changelog/Entry.pm

@@ -97,7 +97,7 @@ sub output {
     $str .= _format_output_block($self->{blank_after_changes});
     $str .= $self->{trailer} . "\n" if defined($self->{trailer});
     $str .= _format_output_block($self->{blank_after_trailer});
-    print $fh $str if defined $fh;
+    print { $fh } $str if defined $fh;
     return $str;
 }
 

+ 1 - 1
scripts/Dpkg/Conf.pm

@@ -167,7 +167,7 @@ sub output {
 	    $opt .= '"';
 	}
 	$opt .= "\n";
-	print $fh $opt if defined $fh;
+	print { $fh } $opt if defined $fh;
 	$ret .= $opt;
     }
     return $ret;

+ 1 - 1
scripts/Dpkg/Control/HashCore.pm

@@ -349,7 +349,7 @@ sub output {
 	    }
 	    # Print it out
             if ($fh) {
-	        print $fh "$key: $value\n"
+	        print { $fh } "$key: $value\n"
 	            or syserr(_g('write error on control data'));
             }
 	    $str .= "$key: $value\n" if defined wantarray;

+ 1 - 1
scripts/Dpkg/Control/Info.pm

@@ -182,7 +182,7 @@ sub output {
     my $str;
     $str .= $self->{source}->output($fh);
     foreach my $pkg (@{$self->{packages}}) {
-	print $fh "\n";
+	print { $fh } "\n";
 	$str .= "\n" . $pkg->output($fh);
     }
     return $str;

+ 4 - 4
scripts/Dpkg/Deps.pm

@@ -551,7 +551,7 @@ sub output {
 	$res .= ' [' . join(' ', @{$self->{arches}}) . ']';
     }
     if (defined($fh)) {
-	print $fh $res;
+	print { $fh } $res;
     }
     return $res;
 }
@@ -937,7 +937,7 @@ sub output {
     my ($self, $fh) = @_;
     my $res = join(', ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps());
     if (defined($fh)) {
-	print $fh $res;
+	print { $fh } $res;
     }
     return $res;
 }
@@ -1042,7 +1042,7 @@ sub output {
     my ($self, $fh) = @_;
     my $res = join(' | ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps());
     if (defined($fh)) {
-	print $fh $res;
+	print { $fh } $res;
     }
     return $res;
 }
@@ -1150,7 +1150,7 @@ sub output {
     my ($self, $fh) = @_;
     my $res = join(', ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps());
     if (defined($fh)) {
-	print $fh $res;
+	print { $fh } $res;
     }
     return $res;
 }

+ 2 - 2
scripts/Dpkg/ErrorHandling.pm

@@ -51,7 +51,7 @@ sub report(@)
 
 sub info($;@)
 {
-    print $info_fh report(_g('info'), @_) if (!$quiet_warnings);
+    print { $info_fh } report(_g('info'), @_) if (!$quiet_warnings);
 }
 
 sub warning($;@)
@@ -72,7 +72,7 @@ sub error($;@)
 
 sub errormsg($;@)
 {
-    print STDERR report(_g('error'), @_);
+    print { *STDERR } report(_g('error'), @_);
 }
 
 sub subprocerr(@)

+ 1 - 1
scripts/Dpkg/IPC.pm

@@ -280,7 +280,7 @@ sub spawn {
     close($opts{error_to_handle}) if exists $opts{error_to_handle};
 
     if ($opts{from_string}) {
-	print $from_string_pipe ${$opts{from_string}};
+	print { $from_string_pipe } ${$opts{from_string}};
 	close($from_string_pipe);
     }
     if ($opts{to_string}) {

+ 1 - 1
scripts/Dpkg/Index.pm

@@ -333,7 +333,7 @@ sub output {
     my $str = '';
     foreach my $key ($self->get_keys()) {
 	if (defined $fh) {
-	    print $fh $self->get_by_key($key) . "\n";
+	    print { $fh } $self->get_by_key($key) . "\n";
 	}
 	if (defined wantarray) {
 	    $str .= $self->get_by_key($key) . "\n";

+ 5 - 5
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -282,19 +282,19 @@ sub output {
 	my @deps = $self->get_dependencies($soname);
 	my $dep_first = shift @deps;
 	$dep_first =~ s/#PACKAGE#/$opts{package}/g if exists $opts{package};
-	print $fh "$soname $dep_first\n" if defined $fh;
+	print { $fh } "$soname $dep_first\n" if defined $fh;
 	$res .= "$soname $dep_first\n" if defined wantarray;
 
 	foreach my $dep_next (@deps) {
 	    $dep_next =~ s/#PACKAGE#/$opts{package}/g if exists $opts{package};
-	    print $fh "| $dep_next\n" if defined $fh;
+	    print { $fh } "| $dep_next\n" if defined $fh;
 	    $res .= "| $dep_next\n" if defined wantarray;
 	}
 	my $f = $self->{objects}{$soname}{fields};
 	foreach my $field (sort keys %{$f}) {
 	    my $value = $f->{$field};
 	    $value =~ s/#PACKAGE#/$opts{package}/g if exists $opts{package};
-	    print $fh "* $field: $value\n" if defined $fh;
+	    print { $fh } "* $field: $value\n" if defined $fh;
 	    $res .= "* $field: $value\n" if defined wantarray;
 	}
 
@@ -313,14 +313,14 @@ sub output {
 	    next if not $opts{template_mode} and
 	            not $sym->arch_is_concerned($self->get_arch());
 	    # Dump symbol specification. Dump symbol tags only in template mode.
-	    print $fh $sym->get_symbolspec($opts{template_mode}), "\n" if defined $fh;
+	    print { $fh } $sym->get_symbolspec($opts{template_mode}), "\n" if defined $fh;
 	    $res .= $sym->get_symbolspec($opts{template_mode}) . "\n" if defined wantarray;
 	    # Dump pattern matches as comments (if requested)
 	    if ($opts{with_pattern_matches} && $sym->is_pattern()) {
 		for my $match (sort { $a->get_symboltempl() cmp
 		                      $b->get_symboltempl() } $sym->get_pattern_matches())
 		{
-		    print $fh '#MATCH:', $match->get_symbolspec(0), "\n" if defined $fh;
+		    print { $fh } '#MATCH:', $match->get_symbolspec(0), "\n" if defined $fh;
 		    $res .= '#MATCH:' . $match->get_symbolspec(0) . "\n" if defined wantarray;
 		}
 	    }

+ 2 - 2
scripts/Dpkg/Source/Package.pm

@@ -392,7 +392,7 @@ sub check_signature {
               timeout => 10);
         if (WIFEXITED($?)) {
             my $gpg_status = WEXITSTATUS($?);
-            print STDERR "$stdout$stderr" if $gpg_status;
+            print { *STDERR } "$stdout$stderr" if $gpg_status;
             if ($gpg_status == 1 or ($gpg_status &&
                 $self->{options}{require_valid_signature}))
             {
@@ -474,7 +474,7 @@ sub extract {
 	    mkdir($srcdir) unless -e $srcdir;
 	    open(my $format_fh, '>', $format_file)
 	        or syserr(_g('cannot write %s'), $format_file);
-	    print $format_fh $self->{fields}{'Format'} . "\n";
+	    print { $format_fh } $self->{fields}{'Format'} . "\n";
 	    close($format_fh);
 	}
     }

+ 2 - 2
scripts/Dpkg/Source/Package/V1.pm

@@ -390,8 +390,8 @@ sub do_build {
     }
 
     if ($ur) {
-        printf(STDERR _g('%s: unrepresentable changes to source') . "\n",
-               $Dpkg::PROGNAME);
+        printf { *STDERR } _g('%s: unrepresentable changes to source') . "\n",
+               $Dpkg::PROGNAME;
         exit(1);
     }
 }

+ 4 - 4
scripts/Dpkg/Source/Package/V2.pm

@@ -221,7 +221,7 @@ sub apply_patches {
     my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied');
     open(my $applied_fh, '>', $applied)
         or syserr(_g('cannot write %s'), $applied);
-    print $applied_fh "# During $opts{usage}\n";
+    print { $applied_fh } "# During $opts{usage}\n";
     my $timestamp = fs_time($applied);
     foreach my $patch ($self->get_patches($dir, %opts)) {
         my $path = File::Spec->catfile($dir, 'debian', 'patches', $patch);
@@ -230,7 +230,7 @@ sub apply_patches {
         $patch_obj->apply($dir, force_timestamp => 1,
                           timestamp => $timestamp,
                           add_options => [ '-E' ]);
-        print $applied_fh "$patch\n";
+        print { $applied_fh } "$patch\n";
     }
     close($applied_fh);
 }
@@ -596,7 +596,7 @@ sub register_patch {
         my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied');
         open(my $applied_fh, '>>', $applied)
             or syserr(_g('cannot write %s'), $applied);
-        print $applied_fh "$patch\n";
+        print { $applied_fh } "$patch\n";
         close($applied_fh) or syserr(_g('cannot close %s'), $applied);
     } elsif (-e $patch) {
         unlink($patch) or syserr(_g('cannot remove %s'), $patch);
@@ -727,7 +727,7 @@ sub update_debian_source_include_binaries {
     open(my $incbin_fh, '>>', $incbin_file)
         or syserr(_g('cannot write %s'), $incbin_file);
     foreach my $binary (@unknown_binaries) {
-        print $incbin_fh "$binary\n";
+        print { $incbin_fh } "$binary\n";
         info(_g('adding %s to %s'), $binary, 'debian/source/include-binaries');
         $self->{allowed_binaries}{$binary} = 1;
     }

+ 2 - 2
scripts/Dpkg/Source/Package/V3/Quilt.pm

@@ -224,7 +224,7 @@ sub _add_line {
     my ($file, $line) = @_;
 
     open(my $file_fh, '>>', $file) or syserr(_g('cannot write %s'), $file);
-    print $file_fh "$line\n";
+    print { $file_fh } "$line\n";
     close($file_fh);
 }
 
@@ -235,7 +235,7 @@ sub _drop_line {
     my @lines = <$file_fh>;
     close($file_fh);
     open($file_fh, '>', $file) or syserr(_g('cannot write %s'), $file);
-    print($file_fh $_) foreach grep { not /^\Q$re\E\s*$/ } @lines;
+    print { $file_fh } $_ foreach grep { not /^\Q$re\E\s*$/ } @lines;
     close($file_fh);
 }
 

+ 3 - 3
scripts/Dpkg/Source/Patch.pm

@@ -125,7 +125,7 @@ sub add_diff_file {
 	    $self->print(*$self->{header}) or syserr(_g('failed to write'));
 	    *$self->{empty} = 0;
 	}
-        print $self $_ or syserr(_g('failed to write'));
+        print { $self } $_ or syserr(_g('failed to write'));
     }
     close($diffgen) or syserr('close on diff pipe');
     wait_child($diff_pid, nocheck => 1,
@@ -557,8 +557,8 @@ sub apply {
 	error_to_string => \$stderr,
     );
     if ($?) {
-	print STDOUT $stdout;
-	print STDERR $stderr;
+	print { *STDOUT } $stdout;
+	print { *STDERR } $stderr;
 	subprocerr('LC_ALL=C patch ' . join(' ', @{$opts{options}}) .
 	           ' < ' . $self->get_filename());
     }

+ 4 - 4
scripts/Dpkg/Source/Quilt.pm

@@ -56,7 +56,7 @@ sub setup_db {
     my $file = $self->get_db_file('.version');
     if (not -e $file) {
         open(my $version_fh, '>', $file) or syserr(_g('cannot write %s'), $file);
-        print $version_fh "2\n";
+        print { $version_fh } "2\n";
         close($version_fh);
     }
     # The files below are used by quilt to know where patches are stored
@@ -65,7 +65,7 @@ sub setup_db {
     $file = $self->get_db_file('.quilt_patches');
     if (not -e $file) {
         open(my $qpatch_fh, '>', $file) or syserr(_g('cannot write %s'), $file);
-        print $qpatch_fh "debian/patches\n";
+        print { $qpatch_fh } "debian/patches\n";
         close($qpatch_fh);
     }
     $file = $self->get_db_file('.quilt_series');
@@ -73,7 +73,7 @@ sub setup_db {
         open(my $qseries_fh, '>', $file) or syserr(_g('cannot write %s'), $file);
         my $series = $self->get_series_file();
         $series = (File::Spec->splitpath($series))[2];
-        print $qseries_fh "$series\n";
+        print { $qseries_fh } "$series\n";
         close($qseries_fh);
     }
 }
@@ -93,7 +93,7 @@ sub write_db {
     open(my $applied_fh, '>', $pc_applied) or
         syserr(_g('cannot write %s'), $pc_applied);
     foreach my $patch (@{$self->{applied_patches}}) {
-        print $applied_fh "$patch\n";
+        print { $applied_fh } "$patch\n";
     }
     close($applied_fh);
 }

+ 1 - 1
scripts/Dpkg/Substvars.pm

@@ -320,7 +320,7 @@ sub output {
     foreach my $vn (sort keys %{$self->{vars}}) {
 	next if /^(?:(?:dpkg|source|binary):(?:Source-)?Version|Space|Tab|Newline|Arch|Source-Version|F:.+)$/;
 	my $line = "$vn=" . $self->{vars}{$vn} . "\n";
-	print $fh $line if defined $fh;
+	print { $fh } $line if defined $fh;
 	$str .= $line;
     }
     return $str;

+ 4 - 4
scripts/dpkg-buildpackage.pl

@@ -444,7 +444,7 @@ if (defined($since)) { push @changes_opts, "-v$since" }
 if (defined($desc)) { push @changes_opts, "-C$desc" }
 
 my $chg = "../$pva.changes";
-print STDERR " dpkg-genchanges @changes_opts >$chg\n";
+print { *STDERR } " dpkg-genchanges @changes_opts >$chg\n";
 open my $changes_fh, '-|', 'dpkg-genchanges', @changes_opts
     or subprocerr('dpkg-genchanges');
 
@@ -452,7 +452,7 @@ open my $out_fh, '>', $chg or syserr(_g('write changes file'));
 
 my $infiles = my $files = '';
 while ($_ = <$changes_fh>) {
-    print $out_fh $_ or syserr(_g('write changes file'));
+    print { $out_fh } $_ or syserr(_g('write changes file'));
     chomp;
 
     if (/^Files:/i) {
@@ -524,14 +524,14 @@ sub mustsetvar {
 
 sub withecho {
     shift while !$_[0];
-    print STDERR " @_\n";
+    print { *STDERR } " @_\n";
     system(@_)
 	and subprocerr("@_");
 }
 
 sub signfile {
     my ($file) = @_;
-    print STDERR " signfile $file\n";
+    print { *STDERR } " signfile $file\n";
     my $qfile = quotemeta($file);
 
     system("(cat ../$qfile ; echo '') | " .

+ 4 - 4
scripts/dpkg-checkbuilddeps.pl

@@ -113,12 +113,12 @@ if ($bc_value) {
 }
 
 if (@unmet) {
-	printf STDERR _g('%s: Unmet build dependencies: '), $Dpkg::PROGNAME;
-	print STDERR join(' ', map { $_->output() } @unmet), "\n";
+	printf { *STDERR } _g('%s: Unmet build dependencies: '), $Dpkg::PROGNAME;
+	print { *STDERR } join(' ', map { $_->output() } @unmet), "\n";
 }
 if (@conflicts) {
-	printf STDERR _g('%s: Build conflicts: '), $Dpkg::PROGNAME;
-	print STDERR join(' ', map { $_->output() } @conflicts), "\n";
+	printf { *STDERR } _g('%s: Build conflicts: '), $Dpkg::PROGNAME;
+	print { *STDERR } join(' ', map { $_->output() } @conflicts), "\n";
 }
 exit 1 if @unmet || @conflicts;
 

+ 2 - 2
scripts/dpkg-distaddfile.pl

@@ -89,14 +89,14 @@ if (open(my $fileslist_fh, '<', $fileslistfile)) {
     while (<$fileslist_fh>) {
         s/\n$//;
         next if m/^(\S+) / && $1 eq $file;
-        print($fileslistnew_fh "$_\n")
+        print { $fileslistnew_fh } "$_\n"
             or syserr(_g('copy old entry to new files list file'));
     }
     close $fileslist_fh or syserr(_g('cannot close %s'), $fileslistfile);
 } elsif ($! != ENOENT) {
     syserr(_g('read old files list file'));
 }
-print($fileslistnew_fh "$file $section $priority\n")
+print { $fileslistnew_fh } "$file $section $priority\n"
     or syserr(_g('write new entry to new files list file'));
 close($fileslistnew_fh) or syserr(_g('close new files list file'));
 rename("$fileslistfile.new", $fileslistfile)

+ 3 - 3
scripts/dpkg-genchanges.pl

@@ -146,11 +146,11 @@ while (@ARGV) {
     } elsif (m/^-B$/) {
 	usageerr(_g('cannot combine %s and %s'), $_, '-S') if is_sourceonly;
 	$include = ARCH_DEP;
-	printf STDERR _g('%s: arch-specific upload - not including arch-independent packages') . "\n", $Dpkg::PROGNAME;
+	printf { *STDERR } _g('%s: arch-specific upload - not including arch-independent packages') . "\n", $Dpkg::PROGNAME;
     } elsif (m/^-A$/) {
 	usageerr(_g('cannot combine %s and %s'), $_, '-S') if is_sourceonly;
 	$include = ARCH_INDEP;
-	printf STDERR _g('%s: arch-indep upload - not including arch-specific packages') . "\n", $Dpkg::PROGNAME;
+	printf { *STDERR } _g('%s: arch-indep upload - not including arch-specific packages') . "\n", $Dpkg::PROGNAME;
     } elsif (m/^-S$/) {
 	usageerr(_g('cannot combine %s and %s'), binary_opt, '-S')
 	    if is_binaryonly;
@@ -447,7 +447,7 @@ if (!is_binaryonly) {
     $origsrcmsg= _g('binary-only upload - not including any source code');
 }
 
-print(STDERR "$Dpkg::PROGNAME: $origsrcmsg\n")
+print { *STDERR } "$Dpkg::PROGNAME: $origsrcmsg\n"
     or syserr(_g('write original source message')) unless $quiet;
 
 $fields->{'Format'} = $substvars->get('Format');

+ 6 - 5
scripts/dpkg-gencontrol.pl

@@ -386,7 +386,7 @@ if (open(my $fileslist_fh, '<', $fileslistfile)) {
 	        && ($3 eq $pkg_type)
 	        && (debarch_eq($2, $fields->{'Architecture'} || '')
 		    || debarch_eq($2, 'all'));
-        print($fileslistnew_fh "$_\n")
+        print { $fileslistnew_fh } "$_\n"
             or syserr(_g('copy old entry to new files list file'));
     }
     close($fileslist_fh) or syserr(_g('close old files list file'));
@@ -398,10 +398,11 @@ $sversion =~ s/^\d+://;
 $forcefilename //= sprintf('%s_%s_%s.%s', $oppackage, $sversion,
                            $fields->{'Architecture'} || '', $pkg_type);
 
-print($fileslistnew_fh $substvars->substvars(sprintf("%s %s %s\n",
-                                             $forcefilename,
-                                             $fields->{'Section'} || '-',
-                                             $fields->{'Priority'} || '-')))
+print { $fileslistnew_fh }
+      $substvars->substvars(sprintf("%s %s %s\n",
+                                    $forcefilename,
+                                    $fields->{'Section'} || '-',
+                                    $fields->{'Priority'} || '-'))
     or syserr(_g('write new entry to new files list file'));
 close($fileslistnew_fh) or syserr(_g('close new files list file'));
 rename("$fileslistfile.new", $fileslistfile)

+ 1 - 1
scripts/dpkg-mergechangelogs.pl

@@ -135,7 +135,7 @@ while (1) {
 if (defined($out_file) and $out_file ne '-') {
     open(my $out_fh, '>', $out_file)
         or syserr(_g('cannot write %s'), $out_file);
-    print $out_fh ((blessed $_) ? "$_" : "$_\n") foreach @result;
+    print { $out_fh } ((blessed $_) ? "$_" : "$_\n") foreach @result;
     close($out_fh) or syserr(_g('cannot write %s'), $out_file);
 } else {
     print ((blessed $_) ? "$_" : "$_\n") foreach @result;

+ 3 - 3
scripts/dpkg-shlibdeps.pl

@@ -464,7 +464,7 @@ if ($stdout) {
 	    or syserr(_g("open old varlist file \`%s' for reading"), $varlistfile);
 	while (my $entry = <$old_fh>) {
 	    next if $entry =~ m/^\Q$varnameprefix\E:/;
-	    print($new_fh $entry)
+	    print { $new_fh } $entry
 	        or syserr(_g("copy old entry to new varlist file \`%s'"),
 	                  "$varlistfile.new");
 	}
@@ -531,7 +531,7 @@ foreach my $field (reverse @depfields) {
         my $obj = deps_parse($dep);
         error(_g('invalid dependency got generated: %s'), $dep) unless defined $obj;
         $obj->sort();
-	print $fh "$varnameprefix:$field=$obj\n";
+	print { $fh } "$varnameprefix:$field=$obj\n";
     }
 }
 
@@ -857,7 +857,7 @@ sub find_packages {
 	chomp($_);
 	if (m/^local diversion |^diversion by/) {
 	    warning(_g('diversions involved - output may be incorrect'));
-	    print(STDERR " $_\n")
+	    print { *STDERR } " $_\n"
 		or syserr(_g('write diversion info to stderr'));
 	} elsif (m/^([-a-z0-9+.:, ]+): (\/.*)$/) {
 	    $cached_pkgmatch{$2} = $pkgmatch->{$2} = [ split(/, /, $1) ];

+ 1 - 1
scripts/t/800_Dpkg_IPC.t

@@ -32,7 +32,7 @@ my $string2;
 
 open $tmp_fh, '>', $tmp1_name
     or die "cannot open $tmp1_name: $!";
-print $tmp_fh $string1;
+print { $tmp_fh } $string1;
 close $tmp_fh;
 
 my $pid = spawn(exec => 'cat',

+ 2 - 2
scripts/t/850_Dpkg_Compression.t

@@ -31,9 +31,9 @@ sub test_write {
 
     $fh = Dpkg::Compression::FileHandle->new();
     open $fh, '>', $filename or die 'open failed';
-    print $fh $lines[0];
+    print { $fh } $lines[0];
     syswrite($fh, $lines[1]);
-    printf $fh '%s', $lines[2];
+    printf { $fh } '%s', $lines[2];
     close $fh or die 'close failed';
 
     &$check_result($filename, 'std functions');

+ 3 - 3
src/t/100_dpkg_divert.t

@@ -51,7 +51,7 @@ sub install_diversions {
     my ($txt) = @_;
     open(my $db_fh, '>', "$admindir/diversions")
         or die "cannot create $admindir/diversions";
-    print $db_fh $txt;
+    print { $db_fh } $txt;
     close($db_fh);
 }
 
@@ -60,13 +60,13 @@ sub install_filelist {
     open(my $fileslist_fh, '>', "$admindir/info/$pkg.list")
         or die "cannot create $admindir/info/$pkg.list";
     for my $file (@files) {
-        print $fileslist_fh "$file\n";
+        print { $fileslist_fh } "$file\n";
     }
     close($fileslist_fh);
     # Only installed packages have their files list considered.
     open(my $status_fh, '>>', "$admindir/status")
         or die "cannot append to $admindir/status";
-    print $status_fh <<"EOF";
+    print { $status_fh } <<"EOF";
 Package: $pkg
 Status: install ok installed
 Version: 0

+ 1 - 0
test/100_critic.t

@@ -65,6 +65,7 @@ my @policies = qw(
     InputOutput::ProhibitOneArgSelect
     InputOutput::ProhibitReadlineInForLoop
     InputOutput::ProhibitTwoArgOpen
+    InputOutput::RequireBracedFileHandleWithPrint
     InputOutput::RequireCheckedOpen
     InputOutput::RequireEncodingWithUTF8Layer
     Miscellanea::ProhibitFormats