I am trying to remove a hash from an array of hashes. I am generating my data structure like this.
push @successarray, { 'hour' => $hour, 'begintime' => $dbfirsttime, 'd +iff' => $diffstring, 'maxDD' => $maxDDL, 'maxDDTF' => $maxDDTF, 'time +frames' => $timeframe, 'maxtpTF' => $timeframe, 'maxtp' => $maxtp, 'y +dayopen' => $ydayopen, 'ydaydiff' => $ydaydiff};
I have tried the delete method. I realise its is deprectated.
for $i ( 0 .. $#successarray ) { if ($successarray[$i]->{'ydayopen'} > $fromopenmove) { delete $successarray[$i]; } }
this seems to work but leaves undefined 'gaps' in my arrays e.g
{ hour=22 maxDDTF=2 maxtp=143 ydaydiff=182 ydayopen=-53 diff=-34 -14 - +2 1 -11 maxtpTF=13 maxDD=29 timeframes=7 begintime=2010-05-27 22:30:0 +0 } { hour=14 maxDDTF=6 maxtp=42 ydaydiff=182 ydayopen=-71 diff=1 -43 -23 +-13 maxtpTF=23 maxDD=34 timeframes=14 begintime=2010-05-28 14:00:00 } { } { } { } { } { hour=03 maxDDTF=1 maxtp=184 ydaydiff=124 ydayopen=-51 diff=2 1 -12 1 + 4 -28 -16 maxtpTF=48 maxDD=1 timeframes=2 begintime=2010-06-15 03:00 +:00 }
I have played with the splice method a little, as this seems a more suitable function, but i cant for the life of me work out the syntax. can anyone please help point me in the right direction? thanks
conal.

In reply to removing a hash from an array of hashes by Conal

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.