Trying to describe code using English leaves room for misinterpretation; using code to describe code is more discrete.

To wit:

#!/usr/bin/perl use strict; use warnings; my %my_hash = (); my $key1 = "T::c"; # The key has no quotation mar +ks in it my $key2 = '"T::c"'; # This key does actually have +the quotes $my_hash{$key1} = 'Nonquoted key'; $my_hash{$key2} = 'Quoted key'; # Show the hard-coded selection from the hash my $test_value = $my_hash{"T::c"}; print "\$test_value = $test_value\n"; # Show the whole hash foreach my $my_key (sort keys %my_hash) { print "\%my_hash{$my_key} = $my_hash{$my_key}\n"; } exit;

Results:

S:\Steve\Dev\PerlMonks\P-2017-05-30@1228-Hash-Key-Quotes>hashkey1.pl $test_value = Nonquoted key %my_hash{"T::c"} = Quoted key %my_hash{T::c} = Nonquoted key


In reply to Re: hash key by marinersk
in thread hash key by aviw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.