in reply to Comparing a value to hash key
This script does not print "YAY IT WORKED", though it should several times.OK, so you have this:
if ( $hash{$remoteIP} > $logDate ) { $hash{$remoteIP} = $logDate; }
...after which, $hash{$remoteIP} will always be less than or equal to $logDate, right?
So, (unless I'm missing something) the problem is that you are only printing "YAY..." if ($hash{$remoteIP} > $logDate), which (as a result of your earlier if statement) is never true.
EDIT:
As for why your substitution works, my guess is that @v might be undefined at $v[$remoteIP]. Do you have use warnings; in your script? If so, do you get a "Use of uninitialized value ..." error? I might throw in something like the following to make sure what you think is happening really is happening, because I don't think $v[$remoteIP] is doing what you think it is doing:
say "\$remote: $remote"; say "\$v[\$remoteIP]: $v[$remoteIP]"; say "\$hash{\$remoteIP}: $hash{$remoteIP}";
|
|---|