Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Doubt regarding parsing

by pavanpvss (Novice)
on Apr 04, 2012 at 18:30 UTC ( [id://963505]=note: print w/replies, xml ) Need Help??


in reply to Re: Doubt regarding parsing
in thread Doubt regarding parsing

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

Replies are listed 'Best First'.
Re^3: Doubt regarding parsing
by GrandFather (Saint) on Apr 05, 2012 at 00:42 UTC

    The double \\ is always OK (although in single quotes it is often redundant). That is not your problem now, and maybe never was. If you are passing a file name on the command line then the default file name is irrelevant. As a sanity check you should:

    die "Can't find $filename\n" if ! -f $filename;

    before the parse line. Note that -f tests for the existence of a file so the die will happen if the file is missing, even if there is a directory of that name.

    Most likely you are passing a file name for a file that exists in a different directory than is the current directory when you run the script. The die line will detect and report that.

    Note that strictures (use strict; use warnings;) pick up bad escape sequences and would often catch your initial error (although not \E). You should always use strictures.

    True laziness is hard work
Re^3: Doubt regarding parsing
by toolic (Bishop) on Apr 04, 2012 at 18:35 UTC
    Copy and paste the exact line that I showed. You have an extra \
Re^3: Doubt regarding parsing
by Not_a_Number (Prior) on Apr 04, 2012 at 18:37 UTC

    Why have you changed the single backslash to a double backslash?

    Update: oops, too late...

      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 done exactly as you have told. But still i find the error "File Not found" . I have cross checked whether i have put the file in C:\ or not. I have done that. Can you please help me out. Thanks in advance

        No, you have not done "exactly" as toolic suggested. You're showing us single quotes around the file name. c.f. his line 3 at his first reply. See also any of the standard references re "interpolation."

        pavanpvss sometimes you are not in the directory that you thought you were in. Try adding the following line to your code and run it before the 'my $filename' line.

        map { print $_ . "\n" } <C:\*>;

        Then check the output for your file. (note the similarities of the C:\ to your filename call).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://963505]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found