Can anyone spot the error in this code?...I've been looking and changing things around for about an hour and can't figure out why it won't work.
Basically I have a text file with this in:
dsfsbdvs8fu8707|Name_of_something_here
Now, in my script I have:
my $code = $in->param('code');
open(FILE,"</path/to/codes.txt");
@data=<FILE>;
close(FILE);
foreach (@data) {
chomp $_;
($un,$dl) = split(/\|/, $_);
if ($code eq $un) {
Do something with Name_of_something_here
} else {
&error("Invalid code : $code");
}
}For some reason I always get the error page, even if I go to the following URL:
http://www.wiredon.net/gt/script.cgi?code=dsfsbdvs8fu8707
Any ideas?.....I'm sure it is a simple mistake but even printing things out to debug didn't help because everything looked as it should. I even compared the value of the query string with the value of $un that I printed out and they were identical. Maybe there is a \s or \n somewhere but I thought chomping would sort that out?
Thanks.
Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/
Basically I have a text file with this in:
dsfsbdvs8fu8707|Name_of_something_here
Now, in my script I have:
Code:
sub get { my $code = $in->param('code');
open(FILE,"</path/to/codes.txt");
@data=<FILE>;
close(FILE);
foreach (@data) {
chomp $_;
($un,$dl) = split(/\|/, $_);
if ($code eq $un) {
Do something with Name_of_something_here
} else {
&error("Invalid code : $code");
}
}
http://www.wiredon.net/gt/script.cgi?code=dsfsbdvs8fu8707
Any ideas?.....I'm sure it is a simple mistake but even printing things out to debug didn't help because everything looked as it should. I even compared the value of the query string with the value of $un that I printed out and they were identical. Maybe there is a \s or \n somewhere but I thought chomping would sort that out?
Thanks.
Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/