Help for this page

Select Code to Download


  1. or download this
    my %set = (
        # Populate this somehow.
    ...
    my @keys = keys %set;
    my $chosen_key = $keys[ rand @keys ];
    my $chosen_value = delete $set{ $chosen_key };
    
  2. or download this
    my %set;
    tie %set, 'DBM::Deep' => { file => 'my_file.db' };
    %set = (
        # Populate as desired, nesting arrays and hashes as appropriate.
    );
    
  3. or download this
    my %set;
    tie %set, 'DBM::Deep' => { file => 'my_file.db' };
    ...
    my @keys = keys %set;
    my $chosen_key = $keys[ rand @keys ];
    my $chosen_value = delete $set{ $chosen_key };
    
  4. or download this
    my $set = DBM::Deep->new({
        file => 'my_file.db',
    ...
    my @keys = keys %{ $set };
    my $chosen_key = $keys[ rand @keys ];
    my $chosen_value = delete $set->{ $chosen_key };