Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Contextual find and replace large config file

by karlgoethebier (Abbot)
on Jan 03, 2019 at 17:23 UTC ( [id://1227990]=note: print w/replies, xml ) Need Help??


in reply to Re: Contextual find and replace large config file
in thread Contextual find and replace large config file

"... JSON doesn't support comments..."

It does if you treat them as data:

#!/usr/bin/env perl use strict; use warnings; use JSON::Tiny qw(decode_json encode_json); use Data::Dump; my $conf = encode_json { foo => qw(bar), nose => qw(cuke), comment => qw(RTFM) }; my $hash = decode_json($conf); dd $hash; __END__ { comment => "RTFM", foo => "bar", nose => "cuke" }

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Replies are listed 'Best First'.
Re^3: Contextual find and replace large config file
by choroba (Cardinal) on Jan 03, 2019 at 17:41 UTC
    Comments in most languages can appear anywhere where insignificant whitespace is possible. Your approach can't transform structures that comment both on the keys and values, as in
    { "name" /* represented as "shortname" in the DB */ : "John Doe" /* full name */,
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      “...Your approach...“

      Nobody is perfect.

      «The Crux of the Biscuit is the Apostrophe»

      perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1227990]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-24 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found