in reply to Re: the sad reality of perl
in thread the sad reality of perl

...or don't fight at all; just... code ;)

Replies are listed 'Best First'.
Re^3: the sad reality of perl
by Aldebaran (Curate) on Oct 10, 2018 at 21:16 UTC

    I've just started looking at JSON data, and for (my) educational purposes, would like to see how the entire task gets done in the greatest generality. It seems that all of the values for 'label' are the ones beginning with caps. JSON material gets bought up in SoPW fairly frequently, but I don't see any tutorial about it as I scroll through. (Maybe a question like this could motivate one.)

    There seems to be a fair amount of CPAN material with it: https://metacpan.org/search?q=JSON

      JSON is pretty easy so you probably won’t see tutorials on it here. It’s also not Perl; tutorials abound elsewhere. If it doesn’t feel easy, slow down. It’s not magic. It’s just plain data notation, extremely similar to data structures in Perl (mostly just anonymous hashes and arrays). It’s also arbitrarily loaded. You can’t make assumptions like “label” or “titlecase.” It’s not meaningful in JSON, just in this particular data structure. This is JSON: [ 1, 2, 5, "Three, Sire!" ]. So is this: { "o":"hai", "name-o":"બિન્ગો" }. It’s easy to play with–

      perl -CSD -MYAML -MJSON -e 'print Dump(decode_json(shift))' '{ "name-o":"બિન્ગો" }'
      ---
      name-o: બિન્ગો
      
      perl -MYAML -MJSON -e 'print Dump(decode_json(shift))' '[ 1, 2, 5, "Th +ree, Sire!" ]' --- - 1 - 2 - 5 - 'Three, Sire!'

      Like any well-defined format it should be handled with a proper parser and writer and not regular expressions. JSON docs are just waiting to be read. :P

      Update, fixed typo/drift in code output.

Re^3: the actual reality of perl
by Anonymous Monk on Oct 10, 2018 at 14:31 UTC
    ...or don't fight at all; just... code ;)

    While code is definitely the best remedy, I believe that not fighting back when being openly, obnoxiously, constantly, attacked is not a viable strategy. Not when we are surrounded by broken robots with pockets full of google cash chanting "python everywhere", which means "perl (and all others) nowhere". That kind of totalitarian ideology is deeply offensive to The Programming Republic of Perl and should be dealt with by something other than ignore-ance. Some will fight with code, others with mere barewords strung together as sentences, and hopefully most will do both.

    "Damn the torpedoes! ...go ahead! ...full speed!".
    Admiral David G. Farragut