0

我正在使用仅使用典型函数打开、打印、关闭来写入 XML 文件的 Perl 程序。XML 文件稍后由 PHP Web 应用程序消化。

#!/usr/bin/perl
#opening file
open FILE, ">derp.xml" or die $!;

#data is created in variables like so...
$first       = '<\?xml version=\"1.0\" encoding=\"UTF-8\" \?>';
$openperson  = '<person>\n';
$name        = '<name>Gary</name>\n';
$birthday    = '<brithday>01/10/1999</birthday>\n';
$car         = '<car>minivan</car>\n';
$closeperson = '</person>\n';

#writing variables to file
print FILE $first;
print FILE $openperson;
print FILE $name;
print FILE $birthday;
print FILE $car;
print FILE $closeperson;
close FILE;

或多或少这基本上是当前系统的工作方式。我相信一定有更好的方法。

4

2 回答 2

6

这些 CPAN 模块是什么:

  • XML::LibXML
  • XML::编写器
  • XML::简单
于 2012-06-14T20:43:38.403 回答
1
于 2012-06-14T20:52:29.213 回答