home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3909
< prev
next >
Wrap
Internet Message Format
|
1991-08-24
|
1KB
Xref: wupost comp.text:5325 comp.org.usenix:1617 alt.sources:3909 comp.sources.bugs:1394 comp.unix.misc:2465 comp.unix.programmer:3029 comp.unix.shell:3318 talk.bizarre:49671 alt.tasteless:3744
Newsgroups: comp.text,comp.org.usenix,comp.unix-wizards,alt.sources,comp.sources.bugs,comp.unix.misc,comp.unix.programmer,comp.unix.shell,talk.bizarre,alt.tasteless
Path: wupost!uunet!psinntp!netlabs!lwall
From: lwall@netlabs.com (Larry Wall)
Subject: most egregious modulus program
Message-ID: <1991Aug23.234156.21347@netlabs.com>
Sender: lwall@netlabs.com (Larry Wall)
Organization: NetLabs, Inc.
Date: Fri, 23 Aug 1991 23:41:56 GMT
Lines: 26
[Sorry 'bout all the crossposting, but there's no rec.nroff.abuse yet...]
The ;login: journal graciously printed my entry to the "Most Egregious
Misuse of Unix Utilities" contest. Unfortunately, the program suffered
a certain amount of bitrot during the publishing process, and several folks
have asked for the correct version. Here's the original (per)version,
for your viewing pleasure and/or nausea:
Task: modulus operator program
Implementation: use line wrapping and diversion in nroff
#!/bin/sh
nroff <<EOF | wc -w
'di xx
'll $2
'll +$2
`echo "10^$1" | bc | tr -d 1 | sed 's/0/0 /g'` \&
'di
EOF
(You invoke it with two numeric arguments. For example, if you say
"modulus 23 10", it prints out 3.)
Larry Wall
lwall@netlabs.com