here is an approach using a few more modules from CPAN. I think it would make it more expandable in the future or readable 6 months from now.
use warnings ; use strict ; use File::Copy ; use Path::Class ; # file(), dir() use File::Find::Rule ; my $INDIR = "C:/output/input"; my $OUTDIR = "C:/output/input/archive"; my $NEWFLE = "COMBINED.output"; my $COUNT = 0; print "[Task started on " . scalar localtime . "]\n"; my $new_file = file( $INDIR, '..', $NEWFLE ); $new_file->touch(); my $FH = $new_file->openw() or die "etc: $!"; my @files = File::Find::Rule->file()->name( qr/.*\.txt/i )->in( $INDIR + ); @files = map{ file( $_ ) } @files; foreach my $file ( @files ) { # Skip file if it is in the archive path. my $archive_path = file( $outdir, $file->basename() ); next if -e $archive_path; # Process file $COUNT++; my @lines = $file->slurp(); print $FH $_ for @lines; # you have to "stringify" Path::Class objects passed to File::Copy move( "$file", "$archive_path" ) or die "Could not move $file to $OU +TDIR: $!\n"; } $FH->close(); print "\n"; print " Found $COUNT files with data to process \n"; print " Reading all file data into memory \n"; print " ${new_file} generated successfully \n"; print "\n"; print "[Task completed in "; print time - $^T . " seconds] \n" ;

In reply to Re: Read contents of multiple files into new file and then move source files? by admiral_grinder
in thread Read contents of multiple files into new file and then move source files? by shadowfox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.