http://qs321.pair.com?node_id=692538


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

Replies are listed 'Best First'.
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.