my(@conf); if(defined($opt{config_file})){ my($buf); $buf = `cat $opt{config_file}`; # slurp if (eval($buf)){ print STDOUT "$me: Read config from $opt{config_file}\n" if $opt{verbose}; } else{ die "$me: Error reading config from $opt{config_file} (fix it!)\n\n"; } } else{ @conf = @default_conf; } #### $ cat 1174639.conf @conf = ( {'step' => 8, 'blur_fwhm' => 4, 'iterations' => 20}, {'step' => 6, 'blur_fwhm' => 3, 'iterations' => 20}, {'step' => 4, 'blur_fwhm' => 2, 'iterations' => 10}, {'step' => 2, 'blur_fwhm' => 1, 'iterations' => 10}, ); #### $ cat 1174639.pl use strict; use warnings; use feature 'say'; use Data::Dumper; my $file = '1174639.conf'; my $buf = `cat $file`; my @conf; eval( $buf ); say Dumper \@conf; #### $ perl 1174639.pl $VAR1 = [ { 'blur_fwhm' => 4, 'step' => 8, 'iterations' => 20 }, { 'step' => 6, 'blur_fwhm' => 3, 'iterations' => 20 }, { 'blur_fwhm' => 2, 'step' => 4, 'iterations' => 10 }, { 'blur_fwhm' => 1, 'step' => 2, 'iterations' => 10 } ];