首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Perl将一个文件的内容导入另一个文件

使用Perl将一个文件的内容导入另一个文件
EN

Stack Overflow用户
提问于 2011-07-19 22:39:18
回答 1查看 2.1K关注 0票数 0
代码语言:javascript
复制
#!/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;

请看上面我放这个的地方:">>>>“。我正在尝试执行复制平面文件内容并将其内容导入fastload脚本的任务。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-20 00:13:03

你能不能不直接做$result=`cat fileA.txt >> fileB.txt;`

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6749008

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档