in reply to Re: Combine files with same extension in new file
in thread Combine files with same extension in new file

Thanks, it works, but it overwrite many times and does not stop
  • Comment on Re^2: Combine files with same extension in new file

Replies are listed 'Best First'.
Re^3: Combine files with same extension in new file
by choroba (Cardinal) on Oct 01, 2015 at 10:28 UTC
    What do you mean? If I understand correctly, when you run it again, it finds output.txt created in the previous run as one of the inputs - that might be the problem. So, before doing glob,
    unlink 'output.txt';
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thanks for answering me. yes as you said, it takes the output.txt file and run it as input. I added unlink 'output.txt'; before the "for my $file (glob '*.tsv')" as you said, but this time nothing happened and even did not make output.txt file. Thanks
        Wait, wait, wait... output.txt doesn't match *.tsv. Moreover, if the input files aren't in the current working directory, you have to specify their path, too:
        glob '/path/to/files/*.tsv'
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      This is great perl code to combine multiple files into one. After adding that extra line before GLOB, it work perfect!!! Thank you very much Choroba!! Roger