$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 = ; 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(); } }