Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at

by sgifford (Prior)
on Jun 17, 2008 at 15:19 UTC ( #692538=note: print w/ replies, xml ) Need Help??


in reply to Re^2: FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at
in thread FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at

I've never used Tie::File::AsHash, but it appears to treat a file as a hash of arrays. You are trying to store a hash reference in it, and it's converting that to a string, HASH(0x875fffc). You would need to either convert it into an array before storing it, then convert back to a hash before using it; or else serialize it, perhaps using Storable.


Comment on Re^3: FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at
Download Code
Re^4: FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at
by earlati2 (Beadle) on Jun 17, 2008 at 16:31 UTC

    I suppose the error was that when I write a reference to a tied hash the reference isteslf loose its object, it's just simply became a string whith an hex address.

    I used separate hash both to store data on file with Tie::File::AsHash and to share with process using IPC::Shareable.

    As said by some of you the reference are not managed, so I must take care of it.

    Now everything works well. Thank to everybody

Re^4: FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at
by earlati2 (Beadle) on Jun 18, 2008 at 06:17 UTC

    You' re right.

    I was wrong just because I think that Tie should manage also inner hash. Now it's all more clear and I fix my program so it now works as expected.

    Thanks to everyone.

      sub ab { $hash = { abc => 'cde', }; return "$hash is the value"; } $str = ab(); with $str how can i access the has of abc and its value. Since, its hash ref in a string..

        Basically, you can't. The memory allocated to $hash is released as soon as ab returns because there is no reference to $hash anymore. If you need a reference to data, keep it as a reference. Don't convert it to a string.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-09-17 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (66 votes), past polls