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

Thank you. That clears a lot up. Currently the script using @ARGV = glob('*.SAM'); will only run to completion if the .txt files are specified on the command line along with it rather than simply running it within a directory containing .txt files. I'm not sure why this is occurring. When I do specify .txt files, I get the error: sh: -c: line 1: syntax error: unexpected end of file.
  • Comment on Re^2: Loading all .txt files within current directory

Replies are listed 'Best First'.
Re^3: Loading all .txt files within current directory
by poj (Abbot) on Jan 31, 2016 at 13:54 UTC

    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
      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.