#!/usr/bin/perl -w use strict; my $config_file=(""); # declare this way to prevent warnings open(RE,"config.pl") || die("cannot open config.txt"); while(my $line=){ $config_file .= $line; } close(RE); my $conf = eval($config_file); # you can look at $@ after #this to see if eval had any errors! print $conf->{'var1'}, "\n"; print $conf->{'var2'}, "\n";