# Config_reader.pm package Config_reader; use base Exporter; use strict; use warnings; # etc while () { chomp; next if /^\s*\#/; next if /^\s*$/; unless (/=/) { die "invalid variable assignment in supporters.db: $_"; } my ($key, $val) = split(/\s*=\s*/,$_,2); $key =~ s/^\s*//; $val =~ s/ *$//g; $config{db}{$key} = $val; $config{$key} = $val; } close DB; ## test.pl use Config_reader qw/%config/; use Data::Dumper \%config; my($host) = $config{db}{db_host_name}; my($db) = $config{db}{db_name }; my($user) = $config{db}{db_user }; my($pw) = $config{db}{db_pw };