[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Another Question -- about "including"



Hi!  I have another question....

I am working on a .cgi that I am trying to make extensible.  It is a very 
complex .cgi, and I would like to be able to split it across many files.  
There are two things I would like to do for this:

1) Is there some equivalent of C's "include"?  "use" says that it must 
take a bareword -- ie, it looks for something in @INC.  I would like to 
be able to reference code in files that are in the same directory as the 
.cgi, or some subdirectory thereof.

2) I have a hash in the main program which matches command actions with 
the functions that work on them.  That is, I have the following code:

$approved_subs{'create_form'} = \&create_form;
$approved_subs{'edit_prefs'} = \&edit_prefs;

Is there some way that I can do the following (not written in perl)

include "preferences.pl";

# in preferences.pl:
$approved_subs{'my_prefs'} = \&my_prefs;
...

So that I can have each file, as I include it, add its list of allowed 
actions to the main list?  It seems that "use" would allow me to add the 
function names to the symbol table for the main program, but I don't 
think it is the same as an "include" in C, in that it wouldn't allow me 
to change data structures in the main program....

Thanks for all suggestions,
Ricky Morse

-----
Pukku


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org