From 3021e910718c4702abe831c7aa53e8a7bf8b135f Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 6 Nov 2002 16:47:00 +0000 Subject: please perl_checker: - local'ize $_ before doing while (<...>) - use "foreach" instead of "for" - remove unneeded parentheses on the right side of infix if/foreach/unless --- perl-install/commands.pm | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'perl-install/commands.pm') diff --git a/perl-install/commands.pm b/perl-install/commands.pm index 4828c506e..f3503eb10 100644 --- a/perl-install/commands.pm +++ b/perl-install/commands.pm @@ -319,11 +319,13 @@ sub head_tail { $n = $n ? shift : 10; local *F; @_ ? open(F, $_[0]) || die "error: can't open file $_[0]\n" : (*F = *STDIN); - local $_; if ($0 eq 'head') { + local $_; while () { $n-- or return; print } } else { - @_ = (); while () { push @_, $_; @_ > $n and shift } + @_ = (); + local $_; + while () { push @_, $_; @_ > $n and shift } print @_; } } @@ -334,7 +336,9 @@ sub strings { my ($h, $o, $n) = getopts(\@_, qw(hon)); $h and die "usage: strings [-o] [-n min-length] []\n"; $n = $n ? shift : 4; - $/ = "\0"; @ARGV = @_; my $l = 0; while (<>) { + $/ = "\0"; @ARGV = @_; my $l = 0; + local $_; + while (<>) { while (/[$printable_chars]{$n,}/og) { printf "%07d ", ($l + length $') if $o; print "$&\n" ; @@ -344,7 +348,9 @@ sub strings { } sub hexdump { - my $i = 0; $/ = \16; @ARGV = @_; while (<>) { + my $i = 0; $/ = \16; @ARGV = @_; + local $_; + while (<>) { printf "%08lX ", $i; $i += 16; print join(" ", (map { sprintf "%02X", $_ } unpack("C*", $_)), (s/[^$printable_chars]/./og, $_)[1]), "\n"; @@ -355,8 +361,10 @@ sub more { @ARGV = @_; require devices; my $tty = devices::make('tty'); - local *IN; open IN, "<$tty" or die "can't open $tty\n"; - my $n = 0; while (<>) { + my $n = 0; + local *IN; open IN, $tty or die "can't open $tty\n"; + local $_; + while (<>) { if (++$n == 25) { my $v = ; $v =~ /^q/ and exit 0; -- cgit v1.2.1