#! /usr/bin/perl use warnings; use strict; use Win32; # automatically loaded with Activestate Perl use File::Basename; # for PrintUsage use Getopt::Long; # for parsing program arguments use FindBin; use lib $FindBin::Bin; use ExcelPerl; $|++; # no suffering from buffering my( $file, $perlCode ); my $worksheetNumber = 1; # use first worksheet as default my $headline = 0; # don't skip a headline as default my $visible = 0; # is of no use in this version my $colSeparator = "\t"; # standard col separator for $_ GetOptions( 'file=s' => \$file, 'sheet=i' => \$worksheetNumber, 'headline=i' => \$headline, 'ane=s' => \$perlCode, # 'visible' => \$visible, 'colseparator' => \$colSeparator, ) or die &PrintUsage(); die &PrintUsage() unless defined $file; $file = Win32::GetFullPathName( $file ); my $xlsPerl = ExcelPerl->new( excelFile => $file, worksheetNumber => $worksheetNumber, ) ->open; #if( $visible ) { $xlsPerl->excel->{Visible} = 1; #} # if # skip all lines until -headline if available $xlsPerl->currentRow( $headline ) if $headline; my @F; while( $xlsPerl->getNextRow( \@F ) ) { # create an alias to @ExcelPerl::F; to be able to access it, it needs to # be a package variable, declared with our or use vars # prepare some other helpful variables local $. = $xlsPerl->currentRow(); local $_ = join($colSeparator, @F ) . "\n"; # try to eval the perl code eval $perlCode; die $@ if $@; @F = (); } # while # ------------------------------------------------------------ sub PrintUsage { my $bin = File::Basename::basename($0); die < =head1 Author Martin Fabiani L =cut