in reply to appending files

A one-liner

perl -ne"print qx[perl -pe1 $_]" test.lst > test.all

Where test.lst contains the list of files 1 per line and their contents is concatenated into test.all

Update: This is a better one that avoids using large amounts of memory for large files:

perl -ne"system 'perl.exe', '-pe1', $_;" test.lst >test.all

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: appending files
by Anonymous Monk on Jan 04, 2006 at 02:28 UTC
    Thank you both for your response.
    Unfortunately, I didn't fully understand Smokemachine's script was doing.
    BrowserUK, When I ran the above code, I continue to get the following error (for both lines): Use of uninitialized value in concatenation (.) or string at testscr.pl
    As I am calling this within another perl script, I added backticks to the beginning and the end of the statement. But everything else remains the same (given that I am using the actual filenames within this line of code).
    I've also tried the following code which seems to compile without any errors but the appended file is blank. Can someone help me see what I'm doing wrong here?
    #accts_to_load.txt contains the filenames of al the files I want to ap +pend together $acctstoload = "/apps/tmp/invs/accts_to_load.txt"; open(ACCTLOAD, $acctstoload) || die("cannot open $acctstoload"); #Here, I want to give a specific name to the file all the split files +are being merged into $batchfile = "mergedfile.txt"; while(<ACCTLOAD>) { `cat $_ >> $batchfile`; }
    I'm not sure what i'm doing wrong. Any suggestions would be appreciated. Thanks.
      Unfortunately, I didn't fully understand Smokemachine's script was doing.

      Did you write the script you are attempting to modify or extend?

      Which is more important to you in the short term?

      • Getting this script to work.
      • Learning how to make this script work yourself?

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.