pavanpvss has asked for the wisdom of the Perl Monks concerning the following question:

use Spreadsheet::ParseExcel; my $filename = shift || "C:\Earthlink.xls"; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse("$filename"); if ( !defined $workbook ) { die $parser->error(), ".\n"; }

I have saved the excel sheet in C:/ drive in 95-2003 format.In the above code i am getting error as File Not Found. I am not getting any value in $workbook. Can anbody please help me ?

Replies are listed 'Best First'.
Re: Doubt regarding parsing
by toolic (Bishop) on Apr 04, 2012 at 18:04 UTC
    Tip #2 from the Basic debugging checklist: print
    use Spreadsheet::ParseExcel; my $filename = shift || "C:\Earthlink.xls"; print "$filename\n"; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse("$filename"); if ( !defined $workbook ) { die $parser->error(), ".\n"; }

    This prints:

    C:arthlink.xls File not found.

    Use single quotes to prevent interpolation of \E:

    my $filename = shift || 'C:\Earthlink.xls';

    A good text editor with syntax highlighting is also helpful in distinguishing literal strings from escape sequences.

    A reply falls below the community's threshold of quality. You may see it by logging in.