What operating system are you using? I have access to Linux and Solaris systems, but cannot duplicate your problem. I get multiple lines on tty output (to the terminal) but when I run the 'df' in backquotes, all the data is on one line, for each device. This is also true if I pipe 'df' output through 'grep', just as you found.

What I don't understand is why the same doesn't happen for you with the backquotes.

As an untested suggestion, you could do your 'split' into an explicit variable declared outside the loop, and check it's size:

my ($tmp, $prev); # ...loop here if (@tmp == 1) { @prev = @tmp; next; }

You could then merge the two arrays to process with the slice. Perhaps not the most elegant solution, but it has the advantage of not failing if the df output ever changes to be single lines in all cases. Since this is done before creating the hash, it should fix at least that part of the problem.


In reply to Re: undefined hash elements by rmcgowan
in thread undefined hash elements by MrTEE

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.