From: Paul Johnson <paul@pjcj.net>
To: Zsh Users List <zsh-users@sunsite.dk>
Subject: Re: Scripting situation I cannot wrap my head around
Date: Wed, 6 Dec 2006 00:43:47 +0100 [thread overview]
Message-ID: <20061205234347.GG2596@pjcj.net> (raw)
In-Reply-To: <20061205154041.GA10583@princo>
On Tue, Dec 05, 2006 at 10:40:41AM -0500, Jean-Rene David wrote:
> * TjL [2006.12.05 07:15]:
> > [...]
> > I am currently writing "verbatims" for a class
> > that I am taking.
> > [...]
> > Here is "normal" dialog:
> >
> > John: How are you today?
> > Tim: I'm good.
> > George: I'm Ok, how are you
> > John: I'm good too.
> > George: Glad to hear it
> > John: Thanks
> > Tim: Yeah, me too
> >
> > Here is verbatim style dialog:
> >
> > John1: How are you today?
> > Tim1: I'm good.
> > George1: I'm Ok, how are you
> > John2: I'm good too.
> > George2: Glad to hear it
> > John3: Thanks
> > Tim2: Yeah, me too
> >
> > [...] You would need separate counters for each
> > person, and you wouldn't know how many people
> > would be a part of the conversation (no fewer
> > than 2 people, probably no more than 10, usually
> > 2-5).
>
> The 'separate counters for each person' sounds
> like a hash to me, and was suggested by others.
>
> However I think a text processing tool would be
> more appropriate than a shell for this kind of
> task:
I was thinking the same thing.
> % perl -ne 'BEGIN { %person=(); } \
> /^([a-zA-Z]+)(:)(.*)$/ && \
> print "$1" . ++$person{$1} . "$2$3\n";' < dialog.file
perl -pe 's/\w+/$& . ++$person{$&}/e' dialog.file
or maybe you don't really want people to understand what you are doing:
perl -pe 's((?=:))?++${$`}?e' dialog.file
Interesting conversation, by the way.
--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
next prev parent reply other threads:[~2006-12-05 23:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-05 7:31 TjL
[not found] ` <237967ef0612050017y1816e7fs66a3bdac8337fac3@mail.gmail.com>
2006-12-05 8:18 ` Mikael Magnusson
2006-12-05 14:35 ` Torur Andreassen
2006-12-05 15:40 ` Jean-Rene David
2006-12-05 23:43 ` Paul Johnson [this message]
2006-12-06 19:34 ` TjL
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061205234347.GG2596@pjcj.net \
--to=paul@pjcj.net \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).