Hi all,
I need some help with the following script. I have a text file (invs_to_load.txt that contains the filenames of all the files I want to append into a single file (this file should contain the name of the 1st file in the list possibly).
I am aware that I should be using unix cat command to achieve this but I am not sure if it is possible to loop through the file and append each file or even if this is the best solution. I have included my script here to provide a better idea of what I'm doing. Thank you in advance for your help.
$dirtoget = "/tmp/invs"; opendir(FILEDIR, $dirtoget) || die ("Cannot open $dirtoget"); @thefiles = grep -T, <$dirtoget/*>; #Store the filenames into an arra +y closedir(FILEDIR); #Calling another perl script that takes each filename as argument #and splits the file into multiple files for further processing foreach $file (@thefiles) { @split_files = `perl split_invs.pl $file`) || next; chomp(@split_files); $temp = join(" ", @split_files); `/tmp/get_acct_info.sh $temp`; #This script takes each split file and + reads some information & #outputs the info to the file output_acct_list.out #Load the main accounts file into a hash to compare against another fi +le #and output accounts only in output_accts_list $origaccts = "/tmp/main_accounts.txt"; open(FILEHANDLE, $origaccts) || die ("Cannot open $origaccts"); %lookup = map {chomp; $_ => undef} <FILEHANDLE>; close(FILEHANDLE); $acctlist = "/tmp/output_acct_list.out"; #Open the file output_acct_li +st for reading open(ACCTLISTFILE, $banlist) || die ("Cannot open $acctlist"); #Output file that will contain filename of the bills that should be lo +aded into our system open($output, '>', '/tmp/invs_load.txt') || die ("Cannot open output file /tmp/invs_load.txt"); while ($line = <ACCTLISTFILE>){ chomp $line; ($filename, undef, undef, undef, $account) = split /\t/, $line; next if exists $lookup{$account}; print $output "$filename\n"; #Print the filename of bills to be lo +aded to invs_load.txt } <Here I want to retrieve the filenames from the above file and append +these files (in order) into a single file prior to loading it into ou +r system> }

In reply to appending files by Anonymous Monk

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.