Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re: &bull;Re: Reference problem? by hotshot
in thread Reference problem? by hotshot

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-18 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found