Perl: read data file as map -


i have configuration file follows,

 name=test  password = test 

i need read data file , set map can set data. now, have tried in way,

        $path_to_file ="c:\\perl\\bin\\data.txt";         open(file, $path_to_file) or die("unable open file");          @data = <file>;         close(file);         print "data ",$data[0],"\n"; 

but not getting desired output. output name=test. can body give other suggestion?. help.

you use tie::file::ashash.

use tie::file::ashash; tie %map, tie::file::ashash::, $path_to_file, split => qr/\s*=\s*/, join => '='  or die "failed open: $!"; $map{password} = 'swordfish'; # changes file! print 'the password ', $map{password}, "\n"; 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -