使用Perl将一个文件的内容导入到另一个文件中 #/usr/bin/perl while(true){ #Obj:opendir,获取从bteq导出的平面文件,并发送到要加载到dev中的fastload脚本 opendir(DIR,“C:/q2refresh/”)或die“无法打开/my/DIR:$!\n”;#用平面文件打开目录 my@Dircontent=readdir; $filetobecopied=“C:/q2refresh/q2_refresh_prod_export.txt”;#从bteq导出的平面文件 $newfile=“C:/Q2刷新/Q2_FastLoadFromFlatFile.txt”#新文件平面文件内容将作为“fastload”复制到 复制($filetobecopied,$newfile)或“无法复制文件。”; 关闭目录; 我的$items_in_dir=@Dircontent; 如果($items_in_dir>1){#检查写入目录的新文件 >>>>#将上面复制的平面文件导入位于C:/q2refresh/q2Fastload.txt的fastload脚本 否则{sleep 100;}#如果在目录中没有发现任何新内容,则什么也不做。 } } 开源,$newfile#读取文件 打开接收器,'>>C:/q2refresh/q2Fastload.txt'#写入文件 而(){ 打印槽$\; } 近源; 关闭水槽;

使用Perl将一个文件的内容导入到另一个文件中 #/usr/bin/perl while(true){ #Obj:opendir,获取从bteq导出的平面文件,并发送到要加载到dev中的fastload脚本 opendir(DIR,“C:/q2refresh/”)或die“无法打开/my/DIR:$!\n”;#用平面文件打开目录 my@Dircontent=readdir; $filetobecopied=“C:/q2refresh/q2_refresh_prod_export.txt”;#从bteq导出的平面文件 $newfile=“C:/Q2刷新/Q2_FastLoadFromFlatFile.txt”#新文件平面文件内容将作为“fastload”复制到 复制($filetobecopied,$newfile)或“无法复制文件。”; 关闭目录; 我的$items_in_dir=@Dircontent; 如果($items_in_dir>1){#检查写入目录的新文件 >>>>#将上面复制的平面文件导入位于C:/q2refresh/q2Fastload.txt的fastload脚本 否则{sleep 100;}#如果在目录中没有发现任何新内容,则什么也不做。 } } 开源,$newfile#读取文件 打开接收器,'>>C:/q2refresh/q2Fastload.txt'#写入文件 而(){ 打印槽$\; } 近源; 关闭水槽;,perl,cp,Perl,Cp,请看上面我写的部分:“>>>>”。我正在尝试执行复制平面文件内容并将其内容导入fastload脚本的任务 这在Perl中是否可能,如果可能,如何实现?您不只是执行$result=`cat fileA.txt>>fileB.txt`什么是快速加载脚本?你能发布一个q2_refresh_prod_export.txt的小例子和你想要的q2Fastload.txt格式吗? #!/usr/bin/perl while (true) { #Obj: open dir, get flat-file whi

请看上面我写的部分:“>>>>”。我正在尝试执行复制平面文件内容并将其内容导入fastload脚本的任务


这在Perl中是否可能,如果可能,如何实现?

您不只是执行
$result=`cat fileA.txt>>fileB.txt`

什么是快速加载脚本?你能发布一个q2_refresh_prod_export.txt的小例子和你想要的q2Fastload.txt格式吗?
#!/usr/bin/perl

while (true) {
#Obj: open dir, get flat-file which was exported from bteq and send to a fastload script to be loaded into dev
    opendir (DIR, "C:/q2refresh/") or die "Cannot open /my/dir: $!\n"; #open directory with the flat-file
    my @Dircontent = readdir DIR;
    $filetobecopied = "C:/q2refresh/q2_refresh_prod_export.txt";  #flatfile exported from bteq
    $newfile = "C:/q2refresh/Q2_FastLoadFromFlatFile.txt"; #new file flat-file contents will be copied to as "fastload"
    copy($filetobecopied, $newfile) or die "File cannot be copied.";
    close DIR;
    my $items_in_dir = @Dircontent;
        if ($items_in_dir > 1) {  # check for new files written to the directory
>>>>          # take the copied FlatFile above and import into a fastload script  located at C:/q2refresh/q2Fastload.txt
        else {sleep 100;} #if found nothing new in directory, do nothing.
        }
}

open SOURCE, $newfile;  #reading to file
open SINK, '>>C:/q2refresh/q2Fastload.txt';   #writing to file
    while (<SOURCE>) {
        print SINK $_;
    }
close SOURCE;
close SINK;