open(CONF, ' ) { chomp $line; # skip blank lines next if $line =~ /^\s*$/; # find named sections if ( $line =~ /^\[(\w+)\]/ ) { $setting = $1; next; } # save values if ( exists $config{$setting} ) { # squash into an array if already set $config{$setting} = ref($config{$setting}) ? [ @{ $config{$setting} }, $line ] : [ $config{$setting}, $line ]; } else { $config{$setting} = $line; } } #### use Data::Dumper; print Data::Dumper::Dumper \%config; #### my $type_match = qr/#DO\s+$config{'type'}/i; foreach my $script_file ( @{ $config{'scripts'} } ) { open(SCRIPT_FILE, $script_file) or die "Can't open script file '$_': $!"; while ( my $line = ) { if ( $line =~ $type_match ) { print "File '$script_file' is the right type"; break; } } }