in reply to Re: Globals printing HASH
in thread Globals printing HASH

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?

Replies are listed 'Best First'.
Re^3: Globals printing HASH
by cdarke (Prior) on Feb 24, 2010 at 16:06 UTC
    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.
Re^3: Globals printing HASH
by AnomalousMonk (Archbishop) on Feb 24, 2010 at 15:53 UTC

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