1use Test::More 'no_plan'; 2use Config::Std; 3 4my $orig_contents = <<EOF; 5[section2] 6 7mutating: 0 8EOF 9 10 11my $tmp_file = 'tmp_file'; 12open my $fh, '>', $tmp_file or die; 13print {$fh} $orig_contents; 14close $fh; 15 16 17read_config $tmp_file, my %config; 18$config{section2}{mutating}++; 19write_config %config; 20 21open $fh, '<', $tmp_file; 22my $contents = do {local $/; <$fh>}; 23close $fh; 24 25ok $contents =~ m/mutating: 1/ => 'Mutation via hash'; 26 27read_config $tmp_file, my $config_ref; 28$config_ref->{section2}{mutating}++; 29write_config $config_ref; 30 31open $fh, '<', $tmp_file; 32$contents = do {local $/; <$fh>}; 33close $fh; 34 35ok $contents =~ m/mutating: 2/ => 'Mutation via hash-ref'; 36 37unlink $tmp_file; 38