0

In Perl can I create my data in Excel worksheet instead of a text file. And use the character "|" as a delimiter. I am using the following code to create a text file

for(my $j = 0; $j < $num2; $j++) { print {$out} $destination[$j]|$IP_one_1[$j]|$IP_one_2[$j]|$IP_one_3[$j]|$IP_one_4[$j]|$reached[$j]|$IP_two_1[$j]|$IP_two_2[$j]|$IP_two_3[$j]|$IP_two_4[$j]\n";

In Perl can I create my data in Excel worksheet instead of a text file. And use the character "|" as a delimiter the expression {$out} is consists of a filename that i have defined earlier and it reads as open my $out,'>', "$file.rec" or die $!;

Cheers,

mkumars
  • 501
  • 3
  • 9
  • 19

1 Answers1

4

In Perl can I create my data in Excel worksheet instead of a text file.

Yes, Spreadsheet::WriteExcel is the de facto standard module for doing this.

And use the character "|" as a delimiter.

No. You have to use the Excel file format if you want to write an Excel file.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • You can read and write in whatever formats you like until you impose restrictions such as "in Excel worksheet" — if you are writing to an Excel worksheet then you have to write your data using the Excel data format. – Quentin Aug 16 '12 at 13:06
  • 1
    Take into account that the OP is using imprecise language and Excel worksheet a [synecdoche](http://enwp.org/synecdoche) for the concept of delimiter separated tabular files. – daxim Aug 16 '12 at 15:08
  • @daxim can i use for loop with the module for example like: `for(my $i = 0; $i<12; $i++);` `$worksheet->write([$i],[$i], 'Hi Excel!'); ` But it is not working this way - any help please – mkumars Aug 16 '12 at 16:35
  • If you use the three argument form for `write`, then the first two arguments should be numbers, not array refs. Get rid of the `[]`s. – Quentin Aug 16 '12 at 16:41