in reply to Re^2: deleting elements in nested hash structure
in thread deleting elements in nested hash structure

last; # <<<< Added 'last' to avoid deleting $first multiple times

It doesn't change the result, but yes, it is a more optimal implementation. I wouldn't code it that way though.

Whilst if( noOverlap ) { do nothing } else { push @todelete }

is functionally equivalent to push @toDelete unless noOverlap;

I find the latter easier on both the eye and the brain.

Hence, I#ll modify the above this way:

push( @toDelete, $first ), last unless $tss{ $ids[ $first ] }{ start } > $tss{ $ids[ $seco +nd ] }{ stop } or $tss{ $ids[ $first ] }{ stop } < $tss{ $ids[ $seco +nd ] }{ start };

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^4: deleting elements in nested hash structure
by NetWallah (Canon) on Jun 02, 2012 at 23:28 UTC
    You are still missing the first correction - instead of using $first directly, you need to use $ids[$first].

    Either

    push( @toDelete, $ids[$first]), last
    or
    delete @tss{ @ids[@toDelete] };

                 I hope life isn't a big joke, because I don't get it.
                       -SNL

      You are right! I was completely oblivious to that error and I will correct it. Thank you.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?