No. How on earth is Perl expected to go from "Foo::Test" which only specifies a package to finding your $URL var within that package. There is simply not enough infomation. Why should it select $URL? Why not %ENV @ISA $DWIM ....? Perl is good but it is not psychic....but more seriously.....

Perhaps you might like to explain what it is you are trying to do (besides use symbolic references which is almost certainly a bad idea and generally unnecessary). There are probably a lot of better ways to do what you want than what you seem to be planning. Anyway this is how to do it (if you must).....

package Foo::Test; $URL = "http://dont.go.here.info/perl/symbolic/references/just_say_no. +htm"; $x = "Foo::Test"; print ${"${x}::URL"};

Also $x must be a GLOBAL for you to be able to access it outside the package. You can't get at a package lexical* (delared with my) from outside the package it is declared in. Globals are another thing best avoided, although there are of course exceptions to every rule.

* Technically you can get at them but certainly not easily.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Dynamic Symbol Table access by tachyon
in thread Dynamic Symbol Table access by eak

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.