OK, I am utterly stumped and stupefied.

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

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.