in reply to Re^2: Loading all .txt files within current directory
in thread Loading all .txt files within current directory

Do you really need that <> magic ?

#!perl use strict; use File::Copy; my $extension = '.tmp'; my @files = glob("*.txt"); for my $file (@files) { print "\n--------- $file-----------\n"; my $backup = $file.$extension; rename($file,$backup); # keep as backup open IN, '<', $backup or die "$!"; open OUT, '>',$file or die "$!"; # overwrite existing while (<IN>) { # process lines print OUT $_; } }
poj

Replies are listed 'Best First'.
Re^4: Loading all .txt files within current directory
by TJCooper (Beadle) on Jan 31, 2016 at 15:34 UTC
    Yes, there was no essential need for < > but I was curious as to why I could not get it to work. Thank you - this approach works perfectly.