Here's some code that attempts to take a string, convert it to a reference to a particular part of a hash of hashes, and give that part another value. I've simplified it down to a test case.
#!/usr/bin/perl $CONFIGS={}; &change_struct(string_to_struct("CONFIGS-hosting_plans-c-title"),"ctit +le"); print $CONFIGS->{hosting_plans}{c}{title}; exit; sub change_struct { my $struct = shift; $$struct = shift; } sub string_to_struct { my $string = shift; my ($var, $keys) = split /-/, $string, 2; $keys = "-$keys"; # safety check would normally be here - removed for simplicity no strict refs; my $ref = $$var; use strict refs; return deref($ref, $keys); } sub deref { return \$_[0] unless $_[1] =~ s/^-([\w\._]+)//; deref ($_[0]->{$1}, $_[1]); }
Under Perl 5.005_03, this gives nothing. Under Perl 5.6, it works fine ( "ctitle" is printed ).
Weirder still -
under the 5.005_03 debugger,
W $CONFIGS->{hosting_plans}{c}{title}
results in
DB<2> c Watchpoint 0: $CONFIGS->{hosting_plans}{c}{title} changed: old value: undef new value: '($@, $!, $^E, $,, $/, $\, $^W) = @saved;package main; + $CONFIGS->{hosting_plans}{c}{title}; ;'
just before the "print". Under the 5.6 debugger, no such problem: the value is changed to ctitle.
What is this? I am lost and bemused, and this has been a hell of a nasty bug so far.
dave hj~
In reply to weird reference bug with perl 5.005_03 by dash2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |