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

um .. shouldn't that be
if ( $tss{ $ids[ $first ] }{ start } > $tss{ $ids[ $second + ] }{ stop } or $tss{ $ids[ $first ] }{ stop } < $tss{ $ids[ $seco +nd ] }{ start } ){ # No Overlap }else{ push @toDelete, $ids[ $first ]; # <<<< Note: changed $ +first to $ids[first] last; # <<<< Added 'last' to avoid deleting $ +first multiple times }

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

Replies are listed 'Best First'.
Re^3: deleting elements in nested hash structure
by BrowserUk (Patriarch) on Jun 02, 2012 at 20:06 UTC
    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?

      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?