hackmare has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monks,
I have a fear. A fear of the darkness of the unknown, of the listlessness that impurity of mind and flimsiness of knowledge causes my frail frame.
A module exists which uses autosubs:
--------------------------
package SVG::Element; $VERSION = "1.0"; use strict; use vars qw(@ISA $AUTOLOAD %autosubs); #@ISA = qw( SVG::XML ); use SVG::XML; my @autosubs=qw( sub1 sub2 sub3 ); %autosubs=map { $_ => 1 } @autosubs; #- - - - - - - - - sub new ($$;@) { my ($proto,$name,%attrs)=@_; my $class=ref($proto) || $proto; my $self={-name => $name}; foreach my $key (keys %attrs) { next if $key=~/^\-/; $self->{$key}=$attrs{$key}; } return bless($self,$class); }
--------------------------
Now what I would like to do is define the names of the subs sub1 sub2 sub3 externally (say, within a file)
And this is where my knowledge of Perl falls down really hard. I would like the subs to be the names of a subset of html tags, such as qw(a href html head ul ol li p h1 h2 b i) for example, ignoring that some of these may be reserved words (or not).
Now here is the crux...
I have no idea to pass the name of the file that contains this list to the program so that it is dymanically generated.
is that even possible? I would prefer to pass it through the constructor. But How do I do that before the object is even instantiated? There must be _smoe_ way to pass the data through. The only thing that I can think of is to generate a list of modules, each module which does the autoloading for its own function set.
The second issue is that I do not want to recompile the script everytime it runs. I would like it to run with a single setup file and keep going with that without having to go through a recompilation each time it is invoked.
Is that possible? Is it even an issue?
Thank you for your wise consideration
Hackmare
|
---|
Replies are listed 'Best First'. | |
---|---|
Heeeelllp!! (A second cry for help - Re: autoloading functions from a text string)
by hackmare (Pilgrim) on Mar 01, 2002 at 14:41 UTC | |
Re: autoloading functions from a text string
by particle (Vicar) on Mar 01, 2002 at 17:24 UTC |