F
Franzl Wisseworst
Mumia W. wrote:
[..]
Another (stupid) question: I presume by the above code the string
"404.html" is meant to be returned in case $current:age has no match in
the tied hash array. But if the page does not exist my $string always
defaults to index 1 of the other array for some reason. In other words: ...
print $string;
.... returns the match in the corresponding hash array correctly as it
should if a match is found, while if no matching $current:age is found,
$match_index always contains an empty string. Not the "404.html" string.
It is no problem to get around it as follows: ...
if ($match_index eq ""){
print "404.html";
}
else {
print $string;
}
.... but I don't think that was the general idea. Perhaps it's something in
the line:
my $string = defined $match_index ? $match_index : "404.html";
Or maybe I'm handling what's returned in a wrong way? In any case, the
right result is there in a roundabout way.
[..]
my $match_index = $obj_en->Indices($current:age);
my $string = defined $match_index ? $match_index : "404.html";
[..]
my $string = $obj_de->Keys($match_index);
Another (stupid) question: I presume by the above code the string
"404.html" is meant to be returned in case $current:age has no match in
the tied hash array. But if the page does not exist my $string always
defaults to index 1 of the other array for some reason. In other words: ...
print $string;
.... returns the match in the corresponding hash array correctly as it
should if a match is found, while if no matching $current:age is found,
$match_index always contains an empty string. Not the "404.html" string.
It is no problem to get around it as follows: ...
if ($match_index eq ""){
print "404.html";
}
else {
print $string;
}
.... but I don't think that was the general idea. Perhaps it's something in
the line:
my $string = defined $match_index ? $match_index : "404.html";
Or maybe I'm handling what's returned in a wrong way? In any case, the
right result is there in a roundabout way.