Read Data from Config file using Perl

Hi All,
Can anyone please explain me how to read data from config file in Perl.

Suppose i have a config file named cfile. The data in config file is

[head]
name=parth
lname=mittal
user=2007
hostname=fluoride

[tail]
username=parthmittal
password=XXXXXX
account=unix
url=www.unix.com

Something like action we perform to fetch data from cfile like
object->tail.username and we get parthmittal
please explaim me how to fetch data and which package and module is used

Hi,

You can use IniConf module to read the config file in perl
or you can use Config::IniFiles too.

Please go through the module with below link

http://search.cpan.org/~shlomif/Config-IniFiles-2.68/lib/Config/IniFiles.pm

Cheers,
Ranga:)

try fetching each value in a variable

username=`awk -F "=" '$1 ~ /username/{print $2}' config.dat`
hostname=`awk -F "=" '$1 ~ /hostname/{print $2}' config.dat`