in reply to Re: Read the values from a file
in thread Read the values from a file

Hi,
Thanks a lot for all your help.
I am a new comer to this area.
I tried to write a program without any module.
In future i would like to edit the file according the brand.
I tried to write a code as follow...
$inputfiletoread = "/config/apollo_logins.cfg"; &Read_Config_File($inputfiletoread); sub Read_Config_File { my($inputfiletoread, ) = @_; chomp($inputfiletoread); if ( -e "$inputfiletoread") { open ( ReadFile , $inputfiletoread); flock( ReadFile, LOCK_EX); @readlines = <ReadFile>; foreach $readentirefile(@readlines) { #If Line Begins Pound Symbol(#) Skip To The Next Line; next if $readentirefile =~ s/^#//; #Check For Line Beginning And Ends With Square Brackets; if ($readentirefile =~ m/^\[/) { if ($readentirefile =~ m/\]+$/) { #Storing the string within [ ] in to string storegroupname; $storegroupname = $readentirefile; $storegroupname =~ s/^\[//; $storegroupname =~ s/\]+$//; } } #If Line is Blank Skip To Next Line; next if $readentirefile =~ s/^$//; #Splitting The Lines INTO Fields using Delimiter; next if $readentirefile =~ m/^\[/; my($optionname, $optionvalue) = split(/=/, $readentirefile); #print "HERE Key=$optionname Val=$optionvalue\n"; } flock (ReadFile, LOCK_UN); close ReadFile; } else { #Error: To Be Written To Log Manager #print " The Path - Name Doesnt Exists \n"; exit(); } }

Thanks a lot... i will follow your suggestion and hope i can ask doubt regarding this..
Regards,
Suresh