I'm parsing HTML. At each tag level, I want to store some variables (tag, print, class, id, defines_class, defines_id).

I'm using HTML::parser which calls a 'start' routine for each start of a tag. Tags are all closed with a call to an 'end' routine (real or simulated for self-closing tags).

So what I'd *like* to do in my parse structure, is to allocate an array for the local vars and alias *names* to the array members for processing in a given 'frame'...like:

my @local_vars; $#local_vars=5; #(don't like the literal 5, but haven' +t gotten so far as to worry about that yet) push @{$this}->{local_vars}}, \@local_vars; #create space for this ta +g's vars assign_names(qw (open_tag, tagprint, cur_class, cur_id, defines_class, + defines_id), \@local_vars); ## this is the questionable 'magic' part +... # now...can use names as one would use local vars.... if ($open_tag eq 'div' and $cur_class eq 'pager') {...
Is this hopelessly idealistic, or is this doable? I figure it's *probably* possible if I was willing to assign to each name something like \$local_vars[0], \$local_vars1... and then use the names with double dollar signs, but I wanted to avoid the ugliness...

In reply to possible to assign symbolic references? by perl-diddler

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.