Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: •Re: Reference problem?

by hotshot (Prior)
on Oct 08, 2003 at 09:51 UTC ( #297522=note: print w/ replies, xml ) Need Help??


in reply to •Re: Reference problem?
in thread Reference problem?

As you said, I indeed expect to get in the volumes key a data or a hash ref (and not both). I had a bug in the program so I added the print lines, and then I got what I got, this is the source of my bug but I can't understand how I can get such a thing.
The following is the full function (with debugs):

sub readClusterVolumes { my %volumesInfo; print "checkpoint 1:\n", Dumper(\%volumesInfo); print "vol: ", $volumesInfo{volumes}, ', ', $volumesInfo{volumes}{ +0}, ', ', $volumesInfo{volumes}{1}, "\n"; my @volumesNodeIDs = &getParam($PARAMS_VOLUMES_NODE_LIST); # shou +ld return (0 1) or nothing dependin whether the parameter exists my (%volumes, $tmp, $volumeKey); $volumesInfo{maxVolId} = &getParam($PARAMS_MAX_VOLUME_ID); $volumesInfo{isInternal} = &getParam($PARAMS_INTERNAL_DISKS); for (my $i = 0; $i < @volumesNodeIDs; $i++) { print "in for loop\n"; ($volumeKey = $PARAMS_NODEX_VOLUMES) =~ s/X/$volumesNodeIDs[$i +]/; $tmp = &getCDBParam($volumeKey, $TRUE); if ($tmp && $tmp ne '') { print "in if, tmp :$tmp\n"; $volumes{$volumesNodeIDs[$i]} = $tmp; } } print "checkpoint 2:\n", Dumper(\%volumesInfo); print "vol: ", $volumesInfo{volumes}, ', ', $volumesInfo{volumes}{ +0}, ', ', $volumesInfo{volumes}{1}, "\n"; if (scalar(keys(%volumes)) == 0) { print "no voluems #######\n"; $volumesInfo{volumes} = 'none'; } else { print "voluems exist #######\n"; $volumesInfo{volumes} = \%volumes; } print "checkpoint 3:\n", Dumper(\%volumesInfo); print "vol: ", $volumesInfo{volumes}, ', ', $volumesInfo{volumes}{ +0}, ', ', $volumesInfo{volumes}{1}, "\n"; return \%volumesInfo; };
I will also add that this happens in the second call to the function. in the first call the output is:
checkpoint 1: $VAR1 = {}; vol: , , in for loop in if, tmp :0 1 2 3 4 in for loop in if, tmp :0 1 2 3 4 checkpoint 2: $VAR1 = { 'volumes' => {}, 'maxVolId' => '4', 'isInternal' => 'false' }; vol: HASH(0x8479e1c), , voluems exist ####### checkpoint 3: $VAR1 = { 'volumes' => { '1' => '0 1 2 3 4', '0' => '0 1 2 3 4' }, 'maxVolId' => '4', 'isInternal' => 'false' }; vol: HASH(0x88d8144), 0 1 2 3 4, 0 1 2 3 4
and in the second call I get:
checkpoint 1: $VAR1 = {}; Use of uninitialized value in print at /vobs/mng/exadmin/var/www/cgi-b +in/lib/clusterEdit.pl line 21, <SESS> line 60. Use of uninitialized value in print at /vobs/mng/exadmin/var/www/cgi-b +in/lib/clusterEdit.pl line 21, <SESS> line 60. Use of uninitialized value in print at /vobs/mng/exadmin/var/www/cgi-b +in/lib/clusterEdit.pl line 21, <SESS> line 60. vol: , , checkpoint 2: $VAR1 = { 'volumes' => {}, 'maxVolId' => 'none', 'isInternal' => 'false' }; vol: HASH(0x847a2c0), , no voluems ####### checkpoint 3: $VAR1 = { 'volumes' => 'none', 'maxVolId' => 'none', 'isInternal' => 'false' }; vol: none, 0 1 2 3 4, 0 1 2 3 4
I removed some Unintialized value... warnings I got, so it will be more clearer. You can see that it somehow 'remembers' the old values from the first call (the last line of the second output). I can't understand how that can be.
All I want under the volumes key is none where there are no volumes, and the volumes themselvs when volumes exist.


Comment on Re: &bull;Re: Reference problem?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-09-02 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (31 votes), past polls