Help for this page

Select Code to Download


  1. or download this
    while (my ($k,$v) = first %hash)
    {
      delete $hash{$_} for $k, @$v;
    }
    
  2. or download this
    use strict;
    use warnings;
    use feature 'say';
    ...
      say "Starting from $k -> [ @$v ]";
      rec_delete %hash => $k;
    }
    
  3. or download this
    Input hash:{ 1 => [2 .. 7], 2 => [1], 3 => [1], 4 => [1], 5 => [1], 6 
    +=> [1], 7 => [1], 8 => [9], 9 => [8] }
    
    Try first then each twice in a row to check that the iteration is rest
    +arted
    ...
         Removing 4 -> [ 1 ]
         Removing 6 -> [ 1 ]
         Removing 7 -> [ 1 ]
    
  4. or download this
    While the hash isn't empty
      Take one key (at random) from the hash
        Delete that key and all connected keys