in reply to Re^11: Complex file manipulation challenge
in thread Complex file manipulation challenge

Yes sure. Of course you are right. I surrender now. And i didn't want to question basic Unix principles. But sometimes i wished/or life would have been a bit easier if some Unix tools would have had a --json or --xml option. Perl has enough devices to replace the classical Unix commands you mention. And yes: you can have comments in JSON files. But as always our beloved brother choroba found the hair in the soup. And the "solution" provided ibidem isn't really satisfying. 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^13: Complex file manipulation challenge
by Tux (Canon) on Aug 18, 2019 at 14:59 UTC

    I only agree with you to the extend of programs/applications not having options for different output.

    OTOH I so much wish that all those applications that generate (erroneous) XML should have an option to generate (correct) CSV. I *really* hate the overhead of XML tags, esp when not needed. And XML is relatively easy to get it wrong (but so are all other formats).

    The *HUGE* advantage of CSV of any other format it that - for 2 dimentional tables (just rows and columns) - the overhead of the "Labels" (headers) is minimal. With (valid) XML, every field in the matrix needs to be labeled causing a huge unneeded overhead in storage. If I do a database table export of 23 million rows, I am quite sure CSV is about 5% of the size of what XML would be. This matters a lot in parsing speed (and generating speed FWIW).

    The big advantage of JSON is that you can generate streams of data, as most whitespace is irrelevant, and that json_pp is able to prettify it if needed.


    Enjoy, Have FUN! H.Merijn
Re^13: Complex file manipulation challenge
by fullermd (Vicar) on Aug 18, 2019 at 15:29 UTC
    % ps -Upostfix PID TT STAT TIME COMMAND 1114 - I 0:08.52 qmgr -l -t fifo -u 57382 - I 0:00.04 pickup -l -t fifo -u 82762 - I 0:01.28 tlsmgr -l -t unix -u % ps -Upostfix --libxo=json {"process-information": {"process": [{"pid":"1114","terminal-name" +:"- ","state":"I","cpu-time":"0:08.52","command":"qmgr -l -t fifo -u" +}, {"pid":"57382","terminal-name":"- ","state":"I","cpu-time":"0:00.0 +4","command":"pickup -l -t fifo -u"}, {"pid":"82762","terminal-name": +"- ","state":"I","cpu-time":"0:01.28","command":"tlsmgr -l -t unix -u +"}]} }

      Yes, i know less or more.

      But look:

      Karls-Mac-mini:~ karl$ ps -Upostfix --libxo=json ps: illegal option -- - usage: ps [-AaCcEefhjlMmrSTvwXx] [-O fmt | -o fmt] [-G gid[,gid...]] [-g grp[,grp...]] [-u [uid,uid...]] [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]] ps [-L]

      Different implementation i guess. That's a part of the problem.

      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