First, you don't need those quotes.

Second, if you use diagnostics or -Mdiagnostics (on the Perl command line), then you'll get an explanation of the error message.

Third, I couldn't see how that error would apply to the code you give so I tried to look up the error in perldiag.pod (which contains all of the error descriptions that use diagnostics can give you). There is no such error. There is this:

Can't coerce array into hash

(F) You used an array where a hash was expected, but the array has no information on how to map from keys to array indices. You can do that only with arrays that have a hash reference at index 0.

So it looks like you got the error message backward and that $temp_dcr{$currentkey} contains a reference to an array (instead of a reference to a hash) for at least one value of $currentkey. (The explanation of the error might be a bit confusing if you don't know about pseudo-hashes, which are being phased out so don't worry about them.)

You can look at how you are populating $temp_dcr to try to figure out how an array reference is getting in there. Or you could debug the problem (use the perl debugger's "x" command or Data::Dumper to display what the contents of $temp_dcr look like before you enter the loop, for example).

        - tye (but my friends call me "Tye")

In reply to (tye)Re: How is this syntax breaking my code? by tye
in thread How is this syntax breaking my code? by wstarrs

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.