in reply to Perl complaining about vars not staying shared

simply make your "state-variables" package globals.
my $prev_index = -1; my $prev_row = 0; my $prev_col = 0; #.... if ( $extension ne "txt" && $extension eq "xls") { my $infile = "../$infile"; my $outfile = "../$outfile"; # Requesting extra modules: use Spreadsheet::ParseExcel; use Data::Dumper; # Openning the file dump open (DUMP, ">$outfile") || warn "Error opening file: $!\n"; select DUMP; # Excel parsing my $parse_excel = new Spreadsheet::ParseExcel(CellHandler => \&cell +_handler, my $workbook = $parse_excel->Parse("$infile"); close DUMP; select STDOUT; } # Define our own cell handler to reduce S::PE's memory use. # This function will be called each time a cell is encountered. # However, it will ignore blank cells so we have to keep track # of our location in the worksheet so that we can pad out blank # cells and rows. # sub cell_handler { my $workbook = $_[0]; my $sheet_index = $_[1]; my $row = $_[2]; my $col = $_[3]; my $cell = $_[4]; # Only process the first worksheet if ($sheet_index > 0) { $workbook->ParseAbort(1); return; } # Reset the col counter between rows $prev_col = 0 if $row != $prev_row; # Add tabs between fields and newlines between rows. Also pad # any missing rows or columns. # print "\n" for $prev_row +1 .. $row; print "\t" for $prev_col +1 .. $col; # Print the UNformatted value of the cell print $cell->{Val}; # Keep track of where we are $prev_row = $row; $prev_col = $col; }

holli, regexed monk