in reply to Re: Re: Re: Re: Extract lines and output...
in thread Extract lines and output...

As you say you don't have to close filehandles in many cases. It is just tidy to do so. If you want to do it the more politiacally correct way you use a lexically scoped variable as FH. This is destroyed when you go out of scope and is well scoped.

while(<*>) { /^$0$/ && next; open my $IN, $_ or die "$_: $!";; open my $OUT,">$_.bak" or die "$_.bak: $!"; print $OUT $_, $/, (<$IN>)[0..3]; }

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print