I'm working on a database using a dbm file indexed with the IP of the user's computer ($ENV{REMOTE_ADDR}). The problem is that if I set it to $dbm_hash{$ENV{REMOTE_ADDR}} I get errors, both in CLI and CGI modes. If I do $userIP = $ENV{REMOTE_ADDR} and then call $dbm_hash($userIP) the same problems occure. However, if I do $userIP = "192.1.1.191" the script will run in CLI, but still errors out in CGI. What am I doing wrong?
~~Guildencrantz#my $userIP = $ENV{REMOTE_ADDR}; my $userIP = "129.168.1.100"; my @formData = split/&/, $ENV{QUERY_STRING}; my %rawData; my $dbEntry; foreach (@formData) { my ($name, $value) = split /=/, $_; $name =~ tr/+/ /; $name =~ s/%([a-f0-9][a-f0-9])/chr(hex($1))/egi; $value =~ tr/+/ /; $value =~ s/%([a-f0-9][a-f0-9])/chr(hex($1))/egi; $rawData{$name} = $value; } $dbEntry = "<TR><TD>$userIP</TD><TD>$rawData{user}</TD><TD>$rawData{se +rver}</TD><TD>$rawData{serverpw}</TD><TD>$rawData{gameDiff}</TD><TD>$ +rawData{worldDiff}</TD><TD>$rawData{map}</TD><TD>$rawData{dod}</TD><T +D>$rawData{teamEnabled}</TD><TD>$rawData{pauseEnabled}</TD><TD>$rawDa +ta{pvpEnabled}</TD><TD>$rawData{joinEnabled}</TD><TD>$rawData{chooseS +tartEnabled}</TD><TD>$rawData{newRestrictionEnabled}</TD></TR>"; my %allIPs; dbmopen(%allIPs, "database/allIPs", 0664) or die "Cannot open allIPs database: $!"; $allIPs{$userIP} = $dbEntry or die "$!"; dbmclose %allIPs;
In reply to dbm troubles by Guildencrantz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |