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


In reply to autoloading functions from a text string by hackmare

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.