Hi, thanks for the response.

I am trying to use a type glob to access values in a hash.

Why?

I read about them in the docs, and I wanted to try them out.

You're trying to reach a variable via a type glob in the symbol table, yet the variable in question isn't in the symbol table. It's a lexical (my) variable.

Hmm...things aren't as straight forward as I was led to believe. Ok, I did some reading about symbol tables, and if I understand them correctly, they are just hashes that contain the variables in your program. The keys in the hash are the variable's names and the values are the variable's values. However, the docs say that the symbol table hash does not contain "my" variables--only dynamic variables. What is a dynamic variable? Anything that isn't a my variable?

Well, if we are always told to use 'my' to declare variables, how does a program create "dynamic variables"?

I discovered this "solution" to my original question:

#use strict; #use warnings; use 5.010; %h = qw{a 1 b 2}; @h = (100, 200, 300); $h = 10; say $h{a}; say $h[0]; say $h; my $href = *h{HASH}; my %hash = %{$href}; say $hash{a}; --output:-- 1 100 10 1

I have a question about this code:

my %h1 = qw{a 1 b 2}; *h2 = \%h1;

How is that different from doing this:

my $href = \%h1;

Is h2 one of those dynamic variables?

say *h2; --output:-- main::h2

Hey, it's in the hash table. Oh boy, I'm on a roll:

say $main::h2{a}; --output:-- 1

In reply to Re^2: type glob by 7stud
in thread type glob by 7stud

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.