That by itself should be fine. I would, however, write the above snippet as something more like:
my $tmp_log = ($Output{host} ||= []); push @$tmp_log, $data; if (10 < @$tmp_log) { shift @$tmp_log; }
However I have to wonder at your data structure. Do you have multiple hosts here and so mean $Output{$host}? Or is %Output full of different kinds of logs, and so you could factor out common code that manipulates each one? Similarly the variable $data seems rather uninformatively named. Most things in a program are data of one kind or another. What kind of data is this data? I would suggest a different structure, but from the snippet you provide I don't have enough to make a concrete suggestion. PS The ||= line I had may confuse. Depending on the skill level of your maintainers, you might be better off expanding that out into:
unless (exists $Output{host}) { $Output{host} = []; } my $tmp_log = $Output{host};

In reply to Re (tilly) 1: More on: memory usage/leaks by tilly
in thread More on: memory usage/leaks by smackdab

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.