perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
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:
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...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') {...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: possible to assign symbolic references?
by ikegami (Patriarch) on Sep 21, 2010 at 22:59 UTC | |
by perl-diddler (Chaplain) on Sep 21, 2010 at 23:08 UTC | |
by ikegami (Patriarch) on Sep 21, 2010 at 23:33 UTC | |
by perl-diddler (Chaplain) on Sep 22, 2010 at 01:03 UTC | |
by ikegami (Patriarch) on Sep 22, 2010 at 02:13 UTC | |
| |
by Anonymous Monk on Sep 21, 2010 at 23:11 UTC | |
|
Re: possible to assign symbolic references?
by Anonymous Monk on Sep 21, 2010 at 23:01 UTC | |
by Argel (Prior) on Sep 22, 2010 at 20:08 UTC |