>>-----Original Message-----
>>From: Rod [mailto:[EMAIL PROTECTED]
>>Sent: marted́ 2 dicembre 2003 16.55
>>To: beginners
>>Subject: Config file
>>
>>
>>What is the best way to read a config file for a perl script.  I have 
>>some very ugly code that can do it, but I would like to find something 
>>cleaner.
>>
>>Thanks,
>>Rod.
>>

## configuration file example <clientMaster.ini>
debug = 1
mailerFlag = 1                 
mailServer = "mailhost.drh.it"
mailDir = "\\\\hpi9670\\c\$\\inetpub\\mailroot\\pickup"
mailDirTemp = "D:\\VoxNauta\\temp"      
t1 = 600        
#t2 = 60                
t2 = 0          
#tempiLog = "cache"     
logRun = "cache"        

Try this simple code for reading the above configuration file:

open FILE_CONF,"clientMaster.ini" || die;
while (<FILE_CONF>) {
        next if (/^#/ || /^;/ || /^$/ || /^\s/);
        eval("\$$_");
}
close FILE_CONF;

# verifying variables read from configuration file
print "debug = $debug\nt1 = $t1\nt2 = $t2\nmailServer = $mailServer\nmailDir = 
$mailDir\nmailDirTemp = $mailDirTemp\n";
print "tempiLog = $tempiLog\nlogRun = $logRun\n";

E.


LOQUENDO S.p.A. 
Vocal Technology and Services 
www.loquendo.it 
[EMAIL PROTECTED]  
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



====================================================================
CONFIDENTIALITY NOTICE
This message and its attachments are addressed solely to the persons
above and may contain confidential information. If you have received
the message in error, be informed that any use of the content hereof
is prohibited. Please return it immediately to the sender and delete
the message. Should you have any questions, please contact us by
replying to [EMAIL PROTECTED] Thank you
====================================================================

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to