scripting - Perl - Import contents of file into another file -
scripting - Perl - Import contents of file into another file -
the below code i'm trying produce trying this:
what i'm trying running bteq script gets info db exports flat-file, flat file picked perl script (the above code), post trying perl import file gets fastload file. create more sense?
while (true) { #objective: open dir, flat-file exported bteq opendir (dir, "c:/q2refresh/") or die "cannot open /my/dir: $!\n"; #open directory flat-file @dircontent = readdir dir; $filetobecopied = "c:/q2refresh/q2_refresh_prod_export.txt"; #flatfile exported bteq $newfile = "c:/q2refresh/q2_fastloadfromflatfile.txt"; #new file flat-file contents copied "fastload" copy($filetobecopied, $newfile) or die "file cannot copied."; close dir; $items_in_dir = @dircontent; if ($items_in_dir > 2) { # > 2 because of "." , ".." -->>>>>> # take copied flatfile above , import fastload script located @ c:/q2refresh/q2fastload.txt } else {sleep 100;} }
i need help implementing above bolded section. how import contents of c:/q2refresh/q2_fastloadfromflatfile.txt
fastload script located @ c:/q2refresh/q2fastload.txt
.
// apologize if newbish, new perl.
thanks.
if ($items_in_dir > 2) { # > 2 because of "." , ".."
well, when including .
, ..
, plus 2 copies of q2_refresh_prod_export.txt
, have more 2 files in directory. if such case should occur q2_refresh_prod_export.txt
not copied, script die
. so else
clause never called.
also, pointless re-create file new place, if going re-create place in second. it's not "cut & paste", actually, physically re-create file new file, not clipboard.
if "import into" mean want append contents of q2_refresh_prod_export.txt
existing q2fastload.txt
, there ways that, such troy suggested in answer, open
, >>
(append to).
you have sort out mean whole $items_in_dir
condition. keeping files , copying files in directory, checking for? whether files have been removed (by other process)?
perl scripting import
Comments
Post a Comment