in reply to Re^6: ref eq "REF"
in thread ref == "REF"
another, well-known breach of this generalization — you can't use references as hash keys
This is a different issue. Hash keys are not scalar values, they are string values. It happens that, very often, the stringified value is the same as the useful scalar value. In some cases, though, this is not true. References are one example, but another would be a variable with a dual value. Consider the following example:
open "non_existent_file"; print $!+0, ": ", $!; $hash{$!}++; for (keys %hash) { print $_+0, ": ", $_; }
Which outputs the following:
2: No such file or directory 0: No such file or directory
The separate numerical value is lost, because the value is stringified as the hash key, not stored as an arbitrary scalar.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: ref eq "REF"
by gaal (Parson) on Oct 18, 2004 at 20:31 UTC | |
by revdiablo (Prior) on Oct 18, 2004 at 23:18 UTC | |
by gaal (Parson) on Oct 19, 2004 at 10:00 UTC |