I just thought this was weird, interesting, and kind of nice... once you understand why perl behaves this way.
#@h{qw(a b c)} doesn't create an @h array. It sets 3 scalar values in
+ the %h hash.
use strict;
use warnings;
use Data::Dumper;
my (%h);
#Note this works with use strict. There is no @h array. This sets $h
+{a}, $h{b}, and $h{c}.
@h{qw(a b c)} = (1, 2, 3);
#Reset $h{b} just to make the point.
$h{b} = 5;
print '%h Hash:' . "\n";
print Dumper(\%h) . "\n\n";
#outputs:
#%h Hash:
#$VAR1 = {
# 'c' => 3,
# 'a' => 1,
# 'b' => 5
# };
#
#
#%sorted Hash:
#$VAR1 = {};
#
UPDATE: Thanks everyone. I should have read hash slice ? No thanks, I'm about to return... first.
Also, I just found that by doing my first phrase match using supersearch (on "list of values"). I had to ask for help, thanks castaway for explaining phrase match. You have to change the list separator to " and then search on "list of values".
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.