while () { chomp; next if /^\s*\#/; # Allow comments next if /^\s*$/; # Allow blank lines unless (/=/) { # All other lines must look like: KEY = VAL die "invalid variable assignment in supporters.db: $_"; } my ($key, $val) = split(/\s*=\s*/,$_,2); # Key and value are separated by equals and maybe space $key =~ s/^\s*//; # Strip any leading space from the key # $val =~ s/(\$(\w+))/$config{$2}/g; # Very simple (read: brittle) variable interpolation $val =~ s/ *$//g; # Strip trailing white space from value $config{'db'}{'$key'} = $val; } close DB;