Hi,

In case anyone was following along and still wants to see the code which
naturally disappeared when we packed up here it is.

    $ head ?
    ==> 1 <==
    subject: foo bar

    ==> 2 <==
    subject: foo
     bar

    ==> 3 <==
    subject: foo
     bar

    ==> 4 <==
    subject: xyzzy

    ==> 5 <==
    subject: fo=?utf-8?Q?=6f?= bar
    $
    $ scan -width 0 -format '%(decode{subject}):%{subject}:%(putlit{subject}):' 
+.
    foo bar:foo bar: foo bar:
    foo bar:foo bar: foo
     bar:
    foo bar:foo bar: foo
     bar:
    xyzzy:xyzzy: xyzzy:
    foo bar:fo=?utf-8?Q?=6f?= bar: fo=?utf-8?Q?=6f?= bar:
    $
    $ scan -width 0 -format '%(msg) %(decode{subject})' +.
    1 foo bar
    2 foo bar
    3 foo bar
    4 xyzzy
    5 foo bar
    $
    $ scan -width 0 -format '%(msg) %(decode{subject})' +. |
    > awk '{m=$1; sub(/[^ ]* /, "", $0)} NR>1 && $0==l {print m} {l=$0}'
    2
    3
    $

And that one-line awk above, as I originally wrote it, re-formatted to
be a usable script, i.e. chmod +x, is

    #! /usr/bin/awk -f

                       { m = $1;  sub(/[^ ]* /, "", $0) }
    NR > 1 && $0 == l  { print m }
                       { l = $0 }

It would be interesting to see the length of a functionally equivalent
Python version as a lot of what awk makes implicit is tedious code in
many other languages and requires much more comprehension for
non-programmers, e.g. method functions of an object, context objects,
etc.

-- 
Cheers, Ralph.

-- 
  Next meeting: Online, Jitsi, Tuesday, 2020-05-05 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to