| nobull67@gmail.com 2006-10-19, 6:56 pm |
|
On Oct 19, 12:56 am, funnybr...@gmail.com wrote:
> I have a hash of hashes.
This is not relevant.
> Some of the values that I put into hash keys have "special" characters
> in them (like "\" or "_"). When these values end up as keys in a hash,
> I get mixed results.
>
> Sometimes displaying the value of the key itself will chop off one of
> the special characters, but leave the rest.
>
> Also, I can display elements of the hash of hashes using:
>
> foreach $item ( keys %hashname )
>
> But if I plug the keys in from another source (such as from an array),
> I cannot display the elements when those keys I plugged in contain "$".
I can see no evidence of this in your example.
> I've also seen it happen when keys I plug in contain a "_", but I
> can't reproduce it in the example below.
> So bottom line question is: How do I work with hash keys when some of
> the values could possibly contain special characters???
No special action is required.
Your problem is that you are mistaking the behaviour of backslashes
within single quotes in Perl.
Try
my $foo = '\';
print "[[[$foo]]]\n";
Then read up on "quote and quote like operators" in Perl.
|