0

I am newbie to perl, I would like to write a perl script to read in multiple text files and look for string and copy the line containing string to an spreadsheet.

Ex: I want to open file csv.txt and look for string "Color" in each line and copy the line to a spread sheet

Color: Name any color

From this line I want to copy Name any color to spreadsheet.

Thanks

4

1 回答 1

2

对于初学者:阅读 CSV 文件,您可以使用 Text:Csv。

http://metacpan.org/pod/Text::CSV

不错的教程: http: //perlmaven.com/how-to-read-a-csv-file-using-perl

您可以使用简单的正则表达式来查找每一行:

if ($line =~ m!Color!){
   #do things if $line contain this word

}

您可以使用此模块编写一个新的 excel 文件:Excel::Writer::XLSX

http://metacpan.org/pod/Excel::Writer::XLSX

如果您仍然遇到问题,请关闭此问题,创建一个新问题,并且不要忘记在其中包含您的代码:https ://stackoverflow.com/questions/how-to-ask

于 2013-01-28T09:45:18.147 回答