Here it is with some extra debug in:
print "Content-Type: text/html \n\n";
# read it into a variable
my $file = read_file($configfile);
print qq|Reading: $file \n<br>|;
my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_select_fields = \((.*?)\)/s and $values = $1;
print qq|GOT: $values \n\n<br><br>|;
# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
print qq|Adding: $tmp[0] ==> $tmp[1]\n<br>|;
$new_hash{$tmp[0]} = $tmp[1];
}
use Data::Dumper;
print qq|Now values:|;
print Dumper(%new_hash);
# values are not in %new_hash
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Code:
use File::Slurp; print "Content-Type: text/html \n\n";
# read it into a variable
my $file = read_file($configfile);
print qq|Reading: $file \n<br>|;
my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_select_fields = \((.*?)\)/s and $values = $1;
print qq|GOT: $values \n\n<br><br>|;
# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
print qq|Adding: $tmp[0] ==> $tmp[1]\n<br>|;
$new_hash{$tmp[0]} = $tmp[1];
}
use Data::Dumper;
print qq|Now values:|;
print Dumper(%new_hash);
# values are not in %new_hash
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!