The error message means that you are trying to dereference a scalar as that does not contain a reference.

You are attempting to deref two arrays, $MyArrayOfArrays, and $MyArrayOfArrays[$i]. One of them doesn't have the value you expect it to have. Look at the last place you assigned to these variables. You may also want to try using Data::Dumper to inspect the structure.

I highly recommend reading and rereading perldsc and perlreftut.

Update: Since I was so terribly slow posting my advice, I thought I'd add an additional comment in an attempt to make this node useful.

You got this error because you are using strict. If you weren't using strict, the error message would disappear and your script would run just fine. Except that it wouldn't work. You'd be working with arrays named @1 or @3 or whatever. If you're lucky, you'd wind up with weirdly mangled output and have one hell of a time figuring out what the problem was. Even worse, everything might seem to work just fine...

I congratulate you on choosing to use strict, and sticking with it, despite getting these error messages. Keep up the good work.


TGI says moo


In reply to Re: Array of arrays problem by TGI
in thread Array of arrays problem by sunwolf78

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.