sub readConfigData { my $filename = shift; # name of the config file. my %settings; open( DATAFILE, "< $filename" ) or die "Can't Open $filename; reason: $!\n"; while ( ) { next unless /\S/; # skip lines of only whitespace next if /^\s*#/; # skip comments s/^\s+|\s+$//g; # trim whitespace in place my ( $cfglabel, $cfgvalue ) = split( /\s*=\s*/, $_, 2 ); $settings{$cfglabel} = $cfgvalue; } close( DATAFILE ) or die "Can't Close $filename; reason: $!\n"; return %settings; }