You get this error when you try to use an array ref as a hashref:
$ perl -e '$aryref= [ qw(one two) ];$aryref->{'camel'}='flea-ridden';' Can't coerce array into hash at -e line 1.
As you do not specify at which line the error occurs, I have to guess. There are two places where you deref a hashref (and thus two hasrefs that could actually be arrayrefs): in the second and third line of your script. The culprits are either $$tmp_string[$SAR_DATA_START] or $rec.

As to why this should work on one OS, and not on another - I would have a long hard look at your input data: you are appear to be using sar output, which tends to be OS specific.

As an aside, you might consider refactoring your data structure. It is quite complicated at the moment (I had to use some paper & pencil drawings to figure it out) and you are appear to be using symbolic references, which is usually not a good sign.

Update: Stopped pretending I have psychic powers.

CU
Robartes-


In reply to Re: Can't coerce array into hash at by robartes
in thread Can't coerce array into hash at by gspot

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.