PERL脚本需要将xml文件从1个FTP服务器传输到另一个FTP服务器,拆分成小文件

时间:2021-10-22 00:25:41

I am a complete stranger to PERL and need some valuable help

我对PERL完全陌生,需要一些有价值的帮助

Here is my problem

这是我的问题

I need to copy a file from ftp server A and place the file into ftp server B When doing this i need to read that file contents and split that big file by matching the pattern of open and ending tags combination and create individual small files and place them in destination ftp server B.

我需要从ftp服务器A复制一个文件并将文件放入ftp服务器B当我这样做时,我需要读取该文件内容并通过匹配开放和结束标签组合的模式拆分该大文件并创建单独的小文件和放置他们在目的地ftp服务器B.

For example if the file name is 20100921.xml and if sample has below format

例如,如果文件名是20100921.xml,并且样本的格式如下

<?xml version="1.0" encoding="utf-8" ?>
<parent>
    <child>
        <code></code>
        <text></text>
    </child>
    <child>
        <code></code>
        <text></text>
    </child>
 </parent>

In the original XML there are lot of child tags instances; i will need to make separate files whose contents will be the ones between tags. In this case there will be 2 new files to be created. Individual file names could be like 20100921_1.xml

在原始XML中有很多子标签实例;我需要制作单独的文件,其内容将是标签之间的内容。在这种情况下,将创建2个新文件。单个文件名可能类似于20100921_1.xml

Everyday there will be only 1 file and the file name will have current date.

每天只有一个文件,文件名将有当前日期。

Can anyone help me with PERL that can do the above. Thanks a lot.

任何人都可以帮我做PERL,可以做到这一点。非常感谢。

1 个解决方案

#1


1  

You can use xml_split for this, probably something like xml_split -l 1 -b 20100921 big.xml.

您可以使用xml_split,可能类似于xml_split -l 1 -b 20100921 big.xml。

xml_split comes with XML::Twig, so it is indeed in Perl, which doesn't really matter, unless you want to extract the relevant code from the tool and include in yours.

xml_split附带了XML :: Twig,所以它确实在Perl中,这并不重要,除非您想从工具中提取相关代码并包含在您的工具中。

#1


1  

You can use xml_split for this, probably something like xml_split -l 1 -b 20100921 big.xml.

您可以使用xml_split,可能类似于xml_split -l 1 -b 20100921 big.xml。

xml_split comes with XML::Twig, so it is indeed in Perl, which doesn't really matter, unless you want to extract the relevant code from the tool and include in yours.

xml_split附带了XML :: Twig,所以它确实在Perl中,这并不重要,除非您想从工具中提取相关代码并包含在您的工具中。