On 27 Jan 2002, at 0:44, Darrell May wrote:

> I would like to use another db file in expanding templates whereby I may
> easily call the variables using the syntax:
> 
> { $variable_name }
> 
> What is the correct way to get 'use e-smith::db;' to read another db file
> in this manner?

I've done some digging through templates.pm and other perldocs 
and I think this is possible but not particularily pretty.  

I tried this to test it out:
- Copied /home/e-smith/configuration to /home/e-smith/myconf
- Changed a single conf entry in myconf, 'SambaWorkgroup', to 
something I'd recognise
- Changed this line:
    tie my %conf, 'esmith::config';
  in the /etc/e-smith/events/actions/conf-samba script to this:
    tie my %conf, 'esmith::config', '/home/e-smith/myconf';
- Then ran /etc/e-smith/events/actions/conf-samba

The new workgroup that I set in the myconf file was used in the 
expanded /etc/smb.conf file.

> My preference would be to have both '/home/e-smith/configuration' plus
> '/home/e-smith/my_new_db' active at the same time.  However if this is not
> possible I'll make do with using '/home/e-smith/my_new_db' alone in this one
> templated file.

Going on the short experiment I did above I don't think you'll be 
able to get both conf files expanded as variables for the templates 
to use.

Another limitation I can see is that if you want to put new template 
fragments into existing templated files then you would need to 
create a new action script to call processTemplate with the 
different 'tie' statement.

Actually I just thought of a (again a little messy) way of getting 
both files expanded to variables.  Try creating an action script that 
includes two 'tie' lines and hash variables, one for the default 
configuration file and another one for your custom configuration file. 
Next, include code to create a merged hash of the two hashes, 
then pass a reference to this combined hash to processTemplate, 
instead of passing \%conf.  Haven't tried it myself but can't see 
why it wouldn't work.

See also 'perldoc Text::Template', 'perldoc esmith::templates.pm' 
and /usr/lib/perl5/site_perl/esmith/templates.pm.

Daniel van Raay


--
Please report bugs to [EMAIL PROTECTED]
Please mail [EMAIL PROTECTED] (only) to discuss security issues
Support for registered customers and partners to [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Archives by mail and http://www.mail-archive.com/devinfo%40lists.e-smith.org

Reply via email to