Hello dear esteemed monks,
This has probably been asked before, but my google-fu cannot get through numerous "I have a warning, what should I do"-type questions. So I dare to ask:
Why does "Odd number of elements in hash assignment" condition cause a warning and not error?
Here are some reasons which may cause this warning:
- hashref assigned to a hash;
- a function returning nothing (not undef) in list context;
- putting array instead of arrayref into hash assignment (as in %hash = (array => qw(foo bar)); );
- misplaced parenthesis somewhere;
- missing argument(s) in a function call.
I wonder which of the abovementioned is a "shoddy but still valid programming practice" and not a coding error, plain and simple? To make matters worse, if the missing hash value comes (well, doesn't come) in the middle of assignment, it causes the values and keys to change places.
But maybe there are still some reasons to keep this warning a warning? I would like to see what I'm missing.
Of course, I can use warnings FATAL => "all"; or just FATAL => "misc"; (here's another WTF - why "misc" category and not, say, "hash"/"odd"?!?!). Still I don't (fortunately) write ALL the code I have to deal with.
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.