Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

spreadsheet::xlsx and terrible stuff

by trickyq (Acolyte)
on May 28, 2012 at 20:10 UTC ( [id://972867]=perlquestion: print w/replies, xml ) Need Help??

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

I am trying to write a script that pulls some data out of certain columns in a spreadsheet and loads them into an array for comparing and updating. I am having trouble actually seeing the data, it keeps giving me a HASH message. the code is this:
@{$sheet->{Cells}[$row]}; my @indexes = (2 .. (2+4-1)); my @dcells = @{$sheet->{Cells}[$row]}[@indexes]; open FILE, ">>forgetyou.txt"; foreach (@dcells) { print FILE ($_); } close FILE;

I wanted to print the data from the cell into a text file as a kind of test to see what columns were coming up etc. and it gives me this:
Spreadsheet::ParseExcel::Cell=HASH(0x70a49a8)Spreadsheet::ParseExcel:: +Cell=HASH(0x70a4a08)Spreadsheet::ParseExcel::Cell=HASH(0x70a4a98)
over and over, I know this is data from the hash but I dont know how to see the actual contents of the cell.

please help
ken

Replies are listed 'Best First'.
Re: spreadsheet::xlsx and terrible stuff
by ww (Archbishop) on May 28, 2012 at 20:44 UTC
    When you see something like HASH(0x70a49a8), Perl is telling you that you're dealing with a reference to a hash rather than the hash itself.

    Possible sources of more information include a good basic Perl text (for example, Learning Perl, O'Reilly) and, here in the Monastery, intro to references and RFC (possible new tutorial) Guide to references; The Basics.

    And, as I noted in a message, please read the formatting instructions which appear below the text input box, each time you go to create a node. <c>...</c> tags would make your code more readable.

Re: spreadsheet::xlsx and terrible stuff
by poj (Abbot) on May 28, 2012 at 21:28 UTC
Re: spreadsheet::xlsx and terrible stuff
by bitingduck (Chaplain) on May 29, 2012 at 05:29 UTC

    A good module to have handy all the time is Data::Dumper. You can feed it data that you can't quite tell how it's structured and it will display it in a somewhat less confusing way, generally showing any nestedness of data structures. It's a convenient way to look at a complicated data structure quickly without having to write your own display.

    And try what poj suggested above.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-18 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found