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"], }, }, )

In reply to Re: Data::Dumper: What the Cabal doesn't want you to know. by tybalt89
in thread Data::Dumper: What the Cabal doesn't want you to know. by Cow1337killr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.