Closed p5pRT closed 16 years ago
I have attached the bug report file and a perl file that uses a perl5.10 interpreter. There are some print statements in the perl file. On my system the print statements will change after a different key to the hash has been assigned. The first print statement will print correctly and the second will
print "unknown" which is the value to the hash right before the second print statement. Please let me know if you get the same behavior and/or how to fix this problem.
Thanks\,
I built a database with hashes of hashes. The value of one of the hash chains is getting changed by a different hash chain. I can put a print statement before and after it and can see that it is changing. The keys are different\, but for some reason they are changing the value from the other key set. If I change one of the keys by a single character\, then I don't see this phenomenon.
2008/10/11 via RT Spencer Myers \perlbug\-followup@​perl\.org:
I have attached the bug report file and a perl file that uses a perl5.10 interpreter. There are some print statements in the perl file. On my system the print statements will change after a different key to the hash has been assigned. The first print statement will print correctly and the second will
print "unknown" which is the value to the hash right before the second print statement. Please let me know if you get the same behavior and/or how to fix this problem.
I'll extract two lines from your script :
$hash{'amis150hx'}{'amis150hxadgx'}{'highest_drive_inv'} = "none"; $hash{'amis150hx'}{'amis150hxadgx'}{'highest_drive_inv'}{'highest_drive_inv_pin_list'} = "unknown";
Here you're assigning to a hash named %none (because your script doesn't use "strict"). There are other instances of this same bug. That's the origin of your bug: you're using the same hash several times\, via different aliases.
The RT System itself - Status changed from 'new' to 'open'
@rgs - Status changed from 'open' to 'resolved'
Spencer Myers (via RT) wrote:
# New Ticket Created by "Spencer Myers" # Please include the string: [perl #59796] # in the subject line of all future correspondence about this issue. # \<URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59796 >
I have attached the bug report file and a perl file that uses a perl5.10 interpreter. There are some print statements in the perl file. On my system the print statements will change after a different key to the hash has been assigned. The first print statement will print correctly and the second will
print "unknown" which is the value to the hash right before the second print statement. Please let me know if you get the same behavior and/or how to fix this problem.
Thanks for your report. This is not a bug in Perl but a subtle bug in your code. The code is accidentally using a "symbolic reference" which lets one refer to a variable by name.
$hash{'amis350ua'}{'amis350uaascb'}{'highest_drive_inv'} is the string 'inv48_b' (assigned on line 3348). That makes $hash{'amis350ua'}{'amis350uaascb'}{'highest_drive_inv'}{highest_drive_inv_pin_list} equivalent to this:
$inv48_b{highest_drive_inv_pin_list};
$hash{'amis350ua'}{'amis350uaascb'}{'highest_drive_inv'} is also the string 'inv48_b' (assigned on line 4149) so it also refers to %inv48_b.
Symbolic references are dangerous and hard to debug. To avoid them\, use strict.
#!/cad/cadapps/bin/perl5.10.0 -w
use strict; my %hash;
$hash{'amis150hx'}{'amis150hxadgx'}{'status'} = "skip"; $hash{'amis150hx'}{'amis150hxadgx'}{'netlist_path'} = "unknown"; ...
And it will error if you try to use a symbolic ref.
Can't use string ("none") as a HASH ref while "strict refs" in use at /Users/schwern/Downloads/perl_bug.pl line 43.
-- 39. Not allowed to ask for the day off due to religious purposes\, on the basis that the world is going to end\, more than once. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/
Migrated from rt.perl.org#59796 (status was 'resolved')
Searchable as RT59796$