From 949a885497d3d05e4dc0dc20e52ecb758d9b677c Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Tue, 14 Nov 2000 15:31:59 +0000 Subject: removed foreach (<... which are eating memory --- perl-install/commands.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'perl-install/commands.pm') diff --git a/perl-install/commands.pm b/perl-install/commands.pm index f9b532958..e2d0f4c0d 100644 --- a/perl-install/commands.pm +++ b/perl-install/commands.pm @@ -261,7 +261,8 @@ sub cp { local (*F, *G); open F, $src or die "can't open $src for reading: $!\n"; open G, "> $dest" or $force or die "can't create $dest : $!\n"; - foreach () { print G $_ } + local $_; + while () { print G $_ } chmod mode($src), $dest; } } @@ -328,10 +329,11 @@ 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') { - foreach () { $n-- or return; print } + while () { $n-- or return; print } } else { - @_ = (); foreach () { push @_, $_; @_ > $n and shift; } + @_ = (); while () { push @_, $_; @_ > $n and shift; } print @_; } } -- cgit v1.2.1