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:my $tmp_log = ($Output{host} ||= []); push @$tmp_log, $data; if (10 < @$tmp_log) { shift @$tmp_log; }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |