use warnings; use strict; use JSON::PP; use YAML::PP; my $data = [ { search=>"Reach Holly Smith for help by sending an email\nto hollysmith\@nosuchdomain.com.", replacement=>"For more information, contact Holly Smith." }, { search=>"For more information, contact Holly Smith at\nhollysmith\@nosuchdomain.com.", replacement=>"For more information, contact Holly Smith." }, { search=>"For more information, contact Holly Smith at (800) 555-1212 or\nvia email to hollysmith\@nosuchdomain.com", replacement=>"For more information, contact Holly Smith." }, ]; my $json = JSON::PP->new->pretty; print $json->encode($data); my $yaml = YAML::PP->new; print $yaml->dump_string($data); __END__ [ { "search" : "Reach Holly Smith for help by sending an email\nto hollysmith@nosuchdomain.com.", "replacement" : "For more information, contact Holly Smith." }, { "replacement" : "For more information, contact Holly Smith.", "search" : "For more information, contact Holly Smith at\nhollysmith@nosuchdomain.com." }, { "replacement" : "For more information, contact Holly Smith.", "search" : "For more information, contact Holly Smith at (800) 555-1212 or\nvia email to hollysmith@nosuchdomain.com" } ] --- - replacement: For more information, contact Holly Smith. search: |- Reach Holly Smith for help by sending an email to hollysmith@nosuchdomain.com. - replacement: For more information, contact Holly Smith. search: |- For more information, contact Holly Smith at hollysmith@nosuchdomain.com. - replacement: For more information, contact Holly Smith. search: |- For more information, contact Holly Smith at (800) 555-1212 or via email to hollysmith@nosuchdomain.com