in reply to Data::Dumper: What the Cabal doesn't want you to know.
Here's an unasked for but suggested YAML version with round trips and a unified diff in the middle, mainly because I haven't played with YAML for a long, long time.
#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11152489 use warnings; my @animals = (qw( cow camel dog cat )); # slightly changed from 1115 +0326 my @foods = (qw( fish pasture meat )); my @places = (qw( wood sea desert )); my $commands = { select => { completion_list => [@animals], commands => { give => { completion_list => \@foods, }, take_to => { completion_list => \@places, }, }, }, kill => { completion_list => [@animals], } }; use YAML qw( DumpFile LoadFile ); my $originalfile = 'original.11152489'; my $changedfile = 'changed.11152489'; DumpFile $originalfile, $commands; $commands->{select}{commands}{give}{completion_list}[0] .= 'es'; DumpFile $changedfile, $commands; system "diff -u $originalfile $changedfile"; use Data::Dump 'dd'; dd 'original', LoadFile $originalfile; use Data::Dump 'dd'; dd 'changed', LoadFile $changedfile;
Outputs:
--- original.11152489 2023-05-30 15:43:38.568028573 -0700 +++ changed.11152489 2023-05-30 15:43:38.571361943 -0700 @@ -9,7 +9,7 @@ commands: give: completion_list: - - fish + - fishes - pasture - meat take_to: ( "original", { kill => { completion_list => ["cow", "camel", "dog", "cat"] }, select => { commands => { give => { completion_list => ["fish", "pasture", "me +at"] }, take_to => { completion_list => ["wood", "sea", "des +ert"] }, }, completion_list => ["cow", "camel", "dog", "cat"], }, }, ) ( "changed", { kill => { completion_list => ["cow", "camel", "dog", "cat"] }, select => { commands => { give => { completion_list => ["fishes", "pasture", " +meat"] }, take_to => { completion_list => ["wood", "sea", "des +ert"] }, }, completion_list => ["cow", "camel", "dog", "cat"], }, }, )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Data::Dumper: What the Cabal doesn't want you to know.
by hippo (Archbishop) on May 31, 2023 at 07:54 UTC |