#!/usr/bin/perl my $cfgfile="./dbconnect"; open (CONFIG,$cfgfile); while () { chomp; # no newline s/#.*//; # no comments s/^\s+//; # no leading white s/\s+$//; # no trailing white next unless length; # anything left? my ($var, $value) = split(/\s*=\s*/, $_, 2); $value=~ s/\r//g; $ConfigValue{$var} = $value; } print "Name--$ConfigValue{'NAME'}";