Help for this page

Select Code to Download


  1. or download this
    my $AoH_new = map ...
    
  2. or download this
    my $AoH_new = map { $AoH_orig->[$_]{'title'} =~ s/ /_/g } @$AoH_orig;
    
  3. or download this
    my $AoH_new = map { $_->{'title'} =~ s/ /_/g } @$AoH_orig;
    
  4. or download this
    my @AoH_new = map {       ## store the result in an array
        my %h = %$_;          ## make a copy of each hashref
        $h{title} =~ s/ /_/g; ## modify a value in the hash copy
        \%h;                  ## return a ref to that copy
    } @$AoH_orig;
    
  5. or download this
    use Storable 'dclone';
    my $AoH_new = dclone $AoH_old; ## copy the old structure
    
    ## change an item in each hash in the new copy
    $_->{title} =~ s/ /_/g for @$AoH_new;