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

I am tring to access the data stored in $oWkS but I keep getting this crazy address error thing - I request the wisdom of the monks! Spreadsheet::ParseExcel::Worksheet=HASH(0x4faa74): No such file or directory - here is the snippet
for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $i +R++) { for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{ +MaxCol} ; $iC++) { $oWkC = $oWkS->{Cells}[$iR][$iC]; print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC) +; } } } # This helps make sure we're using the vars we mean to use use strict; # use DBI; # you'll need to add the dbi +/ oracle info? my $oldrow = 0; my @field_names = qw(fieldname_one fieldname_two fieldname_three); my (@fields,@values); # my $dbh = DBI->connect(...,...,...); # my $sth; open DATA, "< $oWkS" or die "$oWkS: $!\n";

Replies are listed 'Best First'.
Re: accessing data in a hash
by arturo (Vicar) on May 03, 2001 at 20:38 UTC
    $oWkS is not a string scalar, it is a reference to a hash (even more specifically, a hash that's been blessed into the class Spreadsheet::ParseExcel::Worksheet); that's really what your object $oWkS is -- a reference to a hash.

    What your open call does is attempt to open a file with a certain name for *reading*, but when you put a scalar name into the double-quotes where the scalar refers to a hash, you get back a string that consists of the class name the hash has been blessed into, followed by a bit indicating that this is a hash reference. There is no file with that name, so the call fails.

    If you want to read data from the object, you're going to have to access the methods the class provides you with. It *looks* to me like what the data stored in your object is a two-dimensional array, which in Perl is an array of array references. more help than that I cannot responsibly provide, since I'm not at all clear on what you're trying to do.

    HTH

Re: accessing data in a hash
by premchai21 (Curate) on May 03, 2001 at 20:36 UTC
    Spreadsheet::ParseExcel::Worksheet=HASH(0x4faa74) is the "stringified" object. You need to access the filename from the object somehow, rather than using the object itself. Or, depending on the nature of the object, the object may have a way of accessing the data from the file that does not need open at all. Since the "stringified" name of the object is not (or usually is not) a valid filename, it doesn't exist.
Re: accessing data in a hash
by princepawn (Parson) on May 03, 2001 at 20:33 UTC
    Your example looks like a verbatim copy of the docs at Spreadsheet::ParseExcel so I would think it would work. But it looks like the file didn't open successfully. do this:
    use Data::Dumper; print Dumper($oWkS); ### or if that's too much data print Dumper($oWkS->{Cells});

      Thanks! yeah the top of that is cut and paste from CPAN - The parser (the top part of the script) works fine it is my part that is not working per usual = ) thanks I will try that!