Re: Useless Use Of Regexes

Liste des GroupesRevenir à col misc 
Sujet : Re: Useless Use Of Regexes
De : c186282 (at) *nospam* nnada.net (c186282)
Groupes : comp.os.linux.misc
Date : 26. Mar 2025, 05:47:11
Autres entêtes
Message-ID : <kPSdnfFHQI1NG376nZ2dnZfqn_SdnZ2d@giganews.com>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0
On 3/25/25 8:03 AM, Marc Haber wrote:
Anssi Saari <anssi.saari@usenet.mail.kapsi.fi> wrote:
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
Don’t forget the option of JSON-format output, for even easier processing
in scripts than messing around with regexes.
>
Kinda yes, but for a script I'd really like to just get the data
directly in an associative array that I can use as is. Instead of
messing around with jq. I just took a look around in Stack Exchange but
meh. One simplish bash example was this:
>
typeset -A myarray
>
while IFS== read -r key value; do
    myarray["$key"]="$value"
done < <(jq -r '.SITE_DATA | to_entries | .[] | .key + "=" + .value ' file.json)
>
But that still pukes if the data happens to have a numeric value and in
ip route output at least the metric value is numeric. So apparently it
needs to become .key + "=" + (.value|tostring) to handle that.
 This is a classic example why shellscripts are inferior. If you had
written that in python, you could just ingest iproute's output in a
python data structire and access it naturally.
 A very wise German person, today a friend of mine, used to say 25
years ago: "Verwende perl. Shell will man können, dann aber nicht
verwenden." In English that would be "Use Perl. You want to be able to
use Shell, but then don't use it." Today, of course, that would be
python.
   ANYthing but Perl !!!   :-)
   Ok, except maybe Lisp ......
   It is popular to hate Python these days. Not sure
   why except that it's popular/common and, horrors !,
   even the NEWBIES can use it.
   I do still write bash scripts, IF the job is kinda
   simple and straight-forward. However getting 'fancy'
   stuff done in scripts soon becomes anything but
   transparent ... too many squiggles and punctuation
   chars in EXACTLY the right places - a lang extended
   and extended and extended kinda ad-hoc until it's
   easy to get an unreadable mess. Python is much
   easier and more self-documenting. These days it's
   even fairly fast. TONS of libraries and examples
   out there too.
   Today had to make a few mods to a 450-line Python
   pgm I wrote about three years ago. Was NOT hard,
   could follow what I'd writ before. That's not
   always the case with 'C' fer sure  :-)
   Anyway, generally proto everything in Python these
   days, fool around with everything because it's
   easy, and then if appropriate port it over to 'C'
   or Pascal (still love Pascal !).
   Hmmm ... one of the things that attracted me to
   the Unix side long long ago was the 'C-shell' ...
   yet for some reason I never DID anything with it.
   Perhaps time for a second look .....
   As for regex ... avoid whenever possible. WORSE
   syntax than Bash - gobbeldegoop. More plain to
   write a few easy lines of Python for the same
   effect ........

Date Sujet#  Auteur
24 Mar 25 * Useless Use Of Regexes66Lawrence D'Oliveiro
24 Mar 25 +* Re: Useless Use Of Regexes29Pancho
24 Mar 25 i+- Re: Useless Use Of Regexes1The Natural Philosopher
24 Mar 25 i+* Re: Useless Use Of Regexes26Lawrence D'Oliveiro
25 Mar 25 ii+* Re: Useless Use Of Regexes3Marc Haber
26 Mar 25 iii`* Re: Useless Use Of Regexes2Lawrence D'Oliveiro
26 Mar 25 iii `- Re: Useless Use Of Regexes1Marc Haber
25 Mar 25 ii+* Re: Useless Use Of Regexes21Anssi Saari
25 Mar 25 iii`* Re: Useless Use Of Regexes20Marc Haber
26 Mar 25 iii +* Re: Useless Use Of Regexes16Lawrence D'Oliveiro
26 Mar 25 iii i`* Re: Useless Use Of Regexes15Marc Haber
26 Mar 25 iii i `* Re: Useless Use Of Regexes14Lawrence D'Oliveiro
26 Mar 25 iii i  +* Re: Useless Use Of Regexes12Marc Haber
27 Mar 25 iii i  i`* Re: Useless Use Of Regexes11Lawrence D'Oliveiro
27 Mar 25 iii i  i `* Re: Useless Use Of Regexes10Marc Haber
27 Mar 25 iii i  i  `* Re: Useless Use Of Regexes9Lawrence D'Oliveiro
27 Mar 25 iii i  i   `* Re: Useless Use Of Regexes8Marc Haber
27 Mar 25 iii i  i    `* Re: Useless Use Of Regexes7Lawrence D'Oliveiro
28 Mar 25 iii i  i     +* Re: Useless Use Of Regexes5marrgol
28 Mar 25 iii i  i     i+* Re: Useless Use Of Regexes3Chris Ahlstrom
28 Mar 25 iii i  i     ii`* Re: Useless Use Of Regexes2rbowman
29 Mar 25 iii i  i     ii `- Re: Useless Use Of Regexes1Chris Ahlstrom
28 Mar 25 iii i  i     i`- Re: Useless Use Of Regexes1Lawrence D'Oliveiro
1 Apr 25 iii i  i     `- Re: Useless Use Of Regexes1Wayne
27 Mar 25 iii i  `- Re: Useless Use Of Regexes1c186282
26 Mar 25 iii `* Re: Useless Use Of Regexes3c186282
26 Mar 25 iii  `* Re: Useless Use Of Regexes2rbowman
27 Mar 25 iii   `- Re: Useless Use Of Regexes1c186282
25 Mar 25 ii`- Re: Useless Use Of Regexes1Pancho
30 Mar 25 i`- Re: Useless Use Of Regexes1Stéphane CARPENTIER
25 Mar 25 +- Re: Useless Use Of Regexes1Ben Collver
30 Mar 25 `* Re: Useless Use Of Regexes35Stéphane CARPENTIER
30 Mar 25  `* Re: Useless Use Of Regexes34Lawrence D'Oliveiro
30 Mar 25   `* Re: Useless Use Of Regexes33Stéphane CARPENTIER
31 Mar 25    `* Re: Useless Use Of Regexes32Lawrence D'Oliveiro
6 Apr 25     `* Re: Useless Use Of Regexes31Stéphane CARPENTIER
7 Apr 25      `* Re: Useless Use Of Regexes30Lawrence D'Oliveiro
8 Apr 25       +- Re: Useless Use Of Regexes1c186282
8 Apr 25       +* Re: Useless Use Of Regexes21Eli the Bearded
8 Apr 25       i+- Re: Useless Use Of Regexes1c186282
8 Apr 25       i+- Re: Useless Use Of Regexes1Lawrence D'Oliveiro
8 Apr 25       i+* Re: Useless Use Of Regexes17Anssi Saari
9 Apr 25       ii`* Re: Useless Use Of Regexes16Lawrence D'Oliveiro
9 Apr 25       ii +* Re: Useless Use Of Regexes13c186282
9 Apr 25       ii i`* Shell command history (was: Useless Use Of Regexes)12Geoff Clare
12 Apr 25       ii i `* Re: Shell command history (was: Useless Use Of Regexes)11Lawrence D'Oliveiro
13 Apr 25       ii i  +- Re: Shell command history (was: Useless Use Of Regexes)1Eli the Bearded
14 Apr 25       ii i  `* Re: Shell command history9Nuno Silva
14 Apr 25       ii i   `* Re: Shell command history8Lawrence D'Oliveiro
16 Apr 25       ii i    +* Re: Shell command history6Eli the Bearded
16 Apr 25       ii i    i+- Re: Shell command history1Andreas Eder
16 Apr 25       ii i    i`* Re: Shell command history4Lawrence D'Oliveiro
18 Apr 25       ii i    i `* Re: Shell command history3Eli the Bearded
19 Apr 25       ii i    i  `* Re: Shell command history2Lawrence D'Oliveiro
20 Apr 25       ii i    i   `- Re: Shell command history1Eli the Bearded
18 Apr 25       ii i    `- Re: Shell command history1Nuno Silva
9 Apr 25       ii `* Re: Useless Use Of Regexes2Anssi Saari
12 Apr 25       ii  `- Re: Useless Use Of Regexes1Lawrence D'Oliveiro
12 Apr 25       i`- Re: Useless Use Of Regexes1Stéphane CARPENTIER
12 Apr 25       `* Re: Useless Use Of Regexes7Stéphane CARPENTIER
13 Apr 25        `* Re: Useless Use Of Regexes6Lawrence D'Oliveiro
13 Apr 25         +* Re: Useless Use Of Regexes4Stéphane CARPENTIER
14 Apr 25         i`* Re: Useless Use Of Regexes3Lawrence D'Oliveiro
17 Apr 25         i `* Re: Useless Use Of Regexes2Stéphane CARPENTIER
18 Apr 25         i  `- Re: Useless Use Of Regexes1Lawrence D'Oliveiro
13 Apr 25         `- Re: Useless Use Of Regexes1candycanearter07

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal