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

What you expect Perl to do when you print a memory reference?

>perl -e"print {}" HASH(0x225228)

That you're hiding the print inside of Tie::File::AsHash doesn't change anything.

  • Comment on Re^3: FATAL ERROR: Can't use string ("HASH(0x875fffc)") as a HASH ref while "strict refs" in use at
  • Select or 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 12:57 UTC
    What you expect Perl to do when you print a memory reference?

    Sorry, I didn't undestand what you mean .

    The code I have posted previously has the only purpose to show the problem, so if it should seems somewhere strange , don't care to much.

    BTW : I have just discoverred that if I remove the tie directive tie %$self, 'Tie::File::AsHash', $fileTie, split => '=' or die "Problem tying %$self: $!";

    then the program work well, also the 3th print show the contents of the hash.

    I don't known if that is also wath you mean in your comment when you said

    That you're hiding the print inside of Tie::File::AsHash doesn't change anything

    mybe that the tie of blessed $self corrupt some data the pointer

    in that case I will use another hash for the persistence of data

      Sorry, I was presuming you knew Tie::File::AsHash was an interface to a file.

      $self->{'shared_data'} = $p1; means "put $p1 in the file".

      $p2 = $self->{'shared_data'}; means "get $p2 from the file".

      Thats an error, you're supposed to write
      use Tie::File::AsHash; tie my %hash, 'Tie::File::AsHash', 'filename', split => ':' or die "Problem tying %hash: $!";
      no dereferencing nonsense.
        His use of %$self is neither an error (%$self is just as much a hash as %hash) nor inappropriate in this case (since he needs to return a blessed reference).