我正在寻找一些关于如何编写Perl脚本以从excel文件读取数据然后使用读入的数据(希望作为字符串)并将其传递给另一个Perl文件(作为参数)的示例/建议.
目标是有一个表,用户可以在表中键入一些数据(ftp目标或文件名).然后我的程序将使用它自动执行某些数据.它的实现不一定非常优雅......只需要它或多或少地读取数据行.
您可以使用Spreadsheet :: Read,它将委派给相应的模块,以读取各种格式的电子表格,如Excel,OpenOffice和CSV.
另一方面,考虑到您的问题描述,我认为使用标准配置文件格式会更好:
#!/usr/bin/perl
use Config::Std;
read_config 'ftp.ini' => my %config;
for my $file ( keys %config ) {
print "File: '$file'\n";
print "$_: ", $config{$file}->{$_}, "\n"
for qw( site protocol remote_name);
}
Run Code Online (Sandbox Code Playgroud)
ftp.ini:
[c:\Documents and Settings\user\My Documents\this.txt] site = ftp.example.com protocol = ftp remote_name = that.txt
查看这些模块中的概要: