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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Globals printing HASH
by AnomalousMonk (Archbishop) on Feb 24, 2010 at 15:45 UTC

    Something like  HASH(0x68e26a8) is the stringization of a reference to a 'pure', i.e. unblessed, hash. You are printing a reference to a hash, whereas before, presumably, you were printing the tasty goodness of its content.

    A blessed object reference would stringize differently. (See bless.)

    >perl -wMstrict -le "my %hash = ('a' => 1, 'b' => 2, {} => 4); print qq{key '$_' -> value '$hash{$_}'} for keys %hash; my $hashref = \%hash; print qq{hashref is '$hashref'}; my $objectref = bless $hashref; print qq{objectref is '$objectref'}; " key 'a' -> value '1' key 'b' -> value '2' key 'HASH(0x56c19c)' -> value '4' hashref is 'HASH(0x431d5c)' objectref is 'main=HASH(0x431d5c)'
Re: Globals printing HASH
by keszler (Priest) on Feb 24, 2010 at 14:49 UTC
    Sure - it's right there on line 37 . . . oh wait. Nope, without any code posted I don't have a clue.
Re: Globals printing HASH
by cdarke (Prior) on Feb 24, 2010 at 15:10 UTC
    HASH(0x68e26a8) is a reference to a hash. You could be printing a raw object, maybe a class used to overload " but no longer does?
      It seems when I use my ($foo) = { }; to declare some globals it happened if I used my ($foo) = ""; to declare it it fixed the problem. Is there any issues using that way if it works?
        Is there any issues using that way if it works?
        my $foo = {}; # $foo a reference to an empty anonymous hash my $foo = ""; # $foo contains an empty string my $foo; # $foo is undef
        If you are going to use the variable as a reference to a hash then by all means initialise it that way, if you are going to store text there then initialise it as an empty string, if storing numbers then initialise it to zero. If not sure, then leave it undef.

        If you want  $foo to hold an empty string rather than a reference to an anonymous hash, then no, no issue at all.