use strict; use warnings; use 5.010; use Data::Dumper; my $hashFile; my $hashOutFH; my %HoH = ( LOCKS => { SCRIPT => { script1 => { params => [ qw{ a b c } ], shell => q{/bin/bash} }, script2 => { params => [ qw{ -v } ] }, }, }, ); open $hashOutFH, q{>}, \ $hashFile or die qq{open: > \ $hashFile: $!\n}; print $hashOutFH Data::Dumper->Dumpxs( [ \ %HoH ], [ qw{ *HoH } ] ); close $hashOutFH or die qq{close: > \ $hashFile: $!\n}; say q{File content after first write}; print $hashFile; say q{-} x 50; my %HoH1 = do { open my $hashInFH, q{<}, \ $hashFile or die qq{open: < \ $hashFile: $!\n}; my $str = <$hashInFH>; eval $str; %HoH; }; say q{New hash as read in from file}; print Data::Dumper->Dumpxs( [ \ %HoH1 ], [ qw{ *HoH1 } ] ); say q{-} x 50; delete $HoH1{ LOCKS }->{ SCRIPT }->{ script2 }; open $hashOutFH, q{>}, \ $hashFile or die qq{open: > \ $hashFile: $!\n}; print $hashOutFH Data::Dumper->Dumpxs( [ \ %HoH1 ], [ qw{ *HoH } ] ); close $hashOutFH or die qq{close: > \ $hashFile: $!\n}; say q{File content after key delete and second write}; print $hashFile; say q{-} x 50; my %HoH2 = do { open my $hashInFH, q{<}, \ $hashFile or die qq{open: < \ $hashFile: $!\n}; my $str = <$hashInFH>; eval $str; %HoH; }; say q{Second new hash read in from modified file}; print Data::Dumper->Dumpxs( [ \ %HoH2 ], [ qw{ *HoH2 } ] );