Beruflich Dokumente
Kultur Dokumente
Jon Allen
http://perl.jonallen.info - jj@jonallen.info
Perl ‘one-liners’
• Perl’s command-line options can be used to
manipulate data without writing a full script
perl -le ‘print 2+2’
perl -nle ‘/pattern/ and print’ file.txt
• Reading:
– Spreadsheet::ParseExcel
– http://search.cpan.org/dist/Spreadsheet-ParseExcel
• Writing:
– Spreadsheet::WriteExcel
– http://search.cpan.org/dist/Spreadsheet-WriteExcel
use strict;
use warnings;
use Spreadsheet::ParseExcel;
print $cell->Value,"\n";
use strict;
use warnings;
use Spreadsheet::WriteExcel;
$worksheet->write('A1','Hello, World!');
my $excel = Spreadsheet::ParseExcel->new(
NotSetCell => 1,
CellHandler => sub {
my ($workbook,$sheet_index,$row,$col,$cell) = @_;
if (my $value = $cell->Value) {
chomp $value;
print "$value\n" if ($value =~ /$pattern/);
}
}
);
undef $/;
while (<>) {
$excel->Parse(\$_);
}
• See http://perl.jonallen.info/projects/xlstools
• Any ideas?