Hello Monks,
Would someone please explain to me why the following two hash initializations react differently?
Specifically, the QUOTEDSALES assignment is parenthesized in the second, but not in the first.
The indication that I'm seeing is that the last four keys are missing (using the first init) after subsequent processing...
I had drawn the erroneous conclusion that it doesn't matter if parentheses are included or omitted. Would someone please explain the rule that should be applied here?
my $item = { JOBN => $record->[0], CUSTOMERN => $record->[1], JOBDESCRIPTION => $record->[2], QUANTITY => $record->[3], QUOTEDSALES => sprintf "%0.2f", $record->[4] * 0.04, DUEDATE => $record->[5], PRODPLANNER => '5', PRODUCTCODE => '900', SALESMANN => '48', };
my $item = { JOBN => $record->[0], CUSTOMERN => $record->[1], JOBDESCRIPTION => $record->[2], QUANTITY => $record->[3], QUOTEDSALES => sprintf("%0.2f", $record->[4] * 0.04), # <-- NOT +E parens DUEDATE => $record->[5], PRODPLANNER => '5', PRODUCTCODE => '900', SALESMANN => '48', };
In reply to Odd behavior in hash initialization due to missing parens by thezip
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |