Skip to content

Commit 8d063cd

Browse files
author
Larry Wall
committed
a "replacement" for awk and sed
[ Perl is kind of designed to make awk and sed semi-obsolete. This posting will include the first 10 patches after the main source. The following description is lifted from Larry's manpage. --r$ ] Perl is a interpreted language optimized for scanning arbitrary text files, extracting information from those text files, and printing reports based on that information. It's also a good language for many system management tasks. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal). It combines (in the author's opinion, anyway) some of the best features of C, sed, awk, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, Pascal, and even BASIC-PLUS.) Expression syntax corresponds quite closely to C expression syntax. If you have a problem that would ordinarily use sed or awk or sh, but it exceeds their capabilities or must run a little faster, and you don't want to write the silly thing in C, then perl may be for you. There are also translators to turn your sed and awk scripts into perl scripts.
0 parents  commit 8d063cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+20388
-0
lines changed

Configure

Lines changed: 1279 additions & 0 deletions
Large diffs are not rendered by default.

EXTERN.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* $Header: EXTERN.h,v 1.0 87/12/18 13:02:26 root Exp $
2+
*
3+
* $Log: EXTERN.h,v $
4+
* Revision 1.0 87/12/18 13:02:26 root
5+
* Initial revision
6+
*
7+
*/
8+
9+
#undef EXT
10+
#define EXT extern
11+
12+
#undef INIT
13+
#define INIT(x)
14+
15+
#undef DOINIT

INTERN.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* $Header: INTERN.h,v 1.0 87/12/18 13:02:39 root Exp $
2+
*
3+
* $Log: INTERN.h,v $
4+
* Revision 1.0 87/12/18 13:02:39 root
5+
* Initial revision
6+
*
7+
*/
8+
9+
#undef EXT
10+
#define EXT
11+
12+
#undef INIT
13+
#define INIT(x) = x
14+
15+
#define DOINIT

MANIFEST

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
After all the perl kits are run you should have the following files:
2+
3+
Filename Kit Description
4+
-------- --- -----------
5+
Configure 6 Run this first
6+
EXTERN.h 10 Included before foreign .h files
7+
INTERN.h 10 Included before domestic .h files
8+
MANIFEST 8 This list of files
9+
Makefile.SH 4 Precursor to Makefile
10+
README 1 The Instructions
11+
Wishlist 10 Some things that may or may not happen
12+
arg.c 3 Expression evaluation
13+
arg.h 8 Public declarations for the above
14+
array.c 6 Numerically subscripted arrays
15+
array.h 10 Public declarations for the above
16+
cmd.c 7 Command interpreter
17+
cmd.h 9 Public declarations for the above
18+
config.H 9 Sample config.h
19+
config.h.SH 9 Produces config.h.
20+
dump.c 8 Debugging output
21+
form.c 8 Format processing
22+
form.h 10 Public declarations for the above
23+
handy.h 10 Handy definitions
24+
hash.c 9 Associative arrays
25+
hash.h 10 Public declarations for the above
26+
makedepend.SH 9 Precursor to makedepend
27+
makedir.SH 10 Precursor to makedir
28+
malloc.c 7 A version of malloc you might not want
29+
patchlevel.h 1 The current patch level of perl
30+
perl.h 9 Global declarations
31+
perl.man.1 5 The manual page(s), first half
32+
perl.man.2 4 The manual page(s), second half
33+
perl.y 5 Yacc grammar for perl
34+
perly.c 2 The perl compiler
35+
search.c 6 String matching
36+
search.h 10 Public declarations for the above
37+
spat.h 10 Search pattern declarations
38+
stab.c 8 Symbol table stuff
39+
stab.h 10 Public declarations for the above
40+
str.c 4 String handling package
41+
str.h 10 Public declarations for the above
42+
t/README 10 Instructions for regression tests
43+
t/TEST 10 The regression tester
44+
t/base.cond 10 See if conditionals work
45+
t/base.if 10 See if if works
46+
t/base.lex 10 See if lexical items work
47+
t/base.pat 10 See if pattern matching works
48+
t/base.term 10 See if various terms work
49+
t/cmd.elsif 10 See if else-if works
50+
t/cmd.for 10 See if for loops work
51+
t/cmd.mod 10 See if statement modifiers work
52+
t/cmd.subval 10 See if subroutine values work
53+
t/cmd.while 7 See if while loops work
54+
t/comp.cmdopt 9 See if command optimization works
55+
t/comp.cpp 10 See if C preprocessor works
56+
t/comp.decl 10 See if declarations work
57+
t/comp.multiline 10 See if multiline strings work
58+
t/comp.script 10 See if script invokation works
59+
t/comp.term 10 See if more terms work
60+
t/io.argv 10 See if ARGV stuff works
61+
t/io.fs 5 See if directory manipulations work
62+
t/io.inplace 10 See if inplace editing works
63+
t/io.print 10 See if print commands work
64+
t/io.tell 10 See if file seeking works
65+
t/op.append 10 See if . works
66+
t/op.auto 9 See if autoincrement et all work
67+
t/op.chop 10 See if chop works
68+
t/op.cond 10 See if conditional expressions work
69+
t/op.crypt 10 See if crypt works
70+
t/op.do 10 See if subroutines work
71+
t/op.each 10 See if associative iterators work
72+
t/op.exec 10 See if exec and system work
73+
t/op.exp 10 See if math functions work
74+
t/op.flip 10 See if range operator works
75+
t/op.fork 10 See if fork works
76+
t/op.goto 10 See if goto works
77+
t/op.int 10 See if int works
78+
t/op.join 10 See if join works
79+
t/op.list 10 See if array lists work
80+
t/op.magic 10 See if magic variables work
81+
t/op.oct 10 See if oct and hex work
82+
t/op.ord 10 See if ord works
83+
t/op.pat 9 See if esoteric patterns work
84+
t/op.push 7 See if push and pop work
85+
t/op.repeat 10 See if x operator works
86+
t/op.sleep 6 See if sleep works
87+
t/op.split 10 See if split works
88+
t/op.sprintf 10 See if sprintf work
89+
t/op.stat 10 See if stat work
90+
t/op.subst 10 See if substitutions work
91+
t/op.time 10 See if time functions work
92+
t/op.unshift 10 See if unshift works
93+
util.c 9 Utility routines
94+
util.h 10 Public declarations for the above
95+
version.c 10 Prints version of perl
96+
x2p/EXTERN.h 10 Same as above
97+
x2p/INTERN.h 10 Same as above
98+
x2p/Makefile.SH 9 Precursor to Makefile
99+
x2p/a2p.h 8 Global declarations
100+
x2p/a2p.man 8 Manual page for awk to perl translator
101+
x2p/a2p.y 8 A yacc grammer for awk
102+
x2p/a2py.c 7 Awk compiler, sort of
103+
x2p/handy.h 10 Handy definitions
104+
x2p/hash.c 9 Associative arrays again
105+
x2p/hash.h 10 Public declarations for the above
106+
x2p/s2p 1 Sed to perl translator
107+
x2p/s2p.man 10 Manual page for sed to perl translator
108+
x2p/str.c 7 String handling package
109+
x2p/str.h 10 Public declarations for the above
110+
x2p/util.c 9 Utility routines
111+
x2p/util.h 10 Public declarations for the above
112+
x2p/walk.c 1 Parse tree walker

Makefile.SH

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
case $CONFIG in
2+
'')
3+
if test ! -f config.sh; then
4+
ln ../config.sh . || \
5+
ln ../../config.sh . || \
6+
ln ../../../config.sh . || \
7+
(echo "Can't find config.sh."; exit 1)
8+
fi
9+
. config.sh
10+
;;
11+
esac
12+
case "$0" in
13+
*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
14+
esac
15+
echo "Extracting Makefile (with variable substitutions)"
16+
cat >Makefile <<!GROK!THIS!
17+
# $Header: Makefile.SH,v 1.0 87/12/18 16:11:50 root Exp $
18+
#
19+
# $Log: Makefile.SH,v $
20+
# Revision 1.0 87/12/18 16:11:50 root
21+
# Initial revision
22+
#
23+
# Revision 1.0 87/12/18 16:01:07 root
24+
# Initial revision
25+
#
26+
#
27+
28+
CC = $cc
29+
bin = $bin
30+
lib = $lib
31+
mansrc = $mansrc
32+
manext = $manext
33+
CFLAGS = $ccflags -O
34+
LDFLAGS = $ldflags
35+
SMALL = $small
36+
LARGE = $large $split
37+
38+
libs = $libnm -lm
39+
!GROK!THIS!
40+
41+
cat >>Makefile <<'!NO!SUBS!'
42+
43+
public = perl
44+
45+
private =
46+
47+
manpages = perl.man
48+
49+
util =
50+
51+
sh = Makefile.SH makedepend.SH
52+
53+
h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
54+
h2 = hash.h perl.h search.h spat.h stab.h str.h util.h
55+
56+
h = $(h1) $(h2)
57+
58+
c1 = arg.c array.c cmd.c dump.c form.c hash.c malloc.c
59+
c2 = search.c stab.c str.c util.c version.c
60+
61+
c = $(c1) $(c2)
62+
63+
obj1 = arg.o array.o cmd.o dump.o form.o hash.o malloc.o
64+
obj2 = search.o stab.o str.o util.o version.o
65+
66+
obj = $(obj1) $(obj2)
67+
68+
lintflags = -phbvxac
69+
70+
addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7
71+
72+
# grrr
73+
SHELL = /bin/sh
74+
75+
.c.o:
76+
$(CC) -c $(CFLAGS) $(LARGE) $*.c
77+
78+
all: $(public) $(private) $(util)
79+
touch all
80+
81+
perl: $(obj) perl.o
82+
$(CC) $(LDFLAGS) $(LARGE) $(obj) perl.o $(libs) -o perl
83+
84+
perl.c: perl.y
85+
@ echo Expect 2 shift/reduce errors...
86+
yacc perl.y
87+
mv y.tab.c perl.c
88+
89+
perl.o: perl.c perly.c perl.h EXTERN.h search.h util.h INTERN.h handy.h
90+
$(CC) -c $(CFLAGS) $(LARGE) perl.c
91+
92+
# if a .h file depends on another .h file...
93+
$(h):
94+
touch $@
95+
96+
perl.man: perl.man.1 perl.man.2
97+
cat perl.man.1 perl.man.2 >perl.man
98+
99+
install: perl perl.man
100+
# won't work with csh
101+
export PATH || exit 1
102+
- mv $(bin)/perl $(bin)/perl.old
103+
- if test `pwd` != $(bin); then cp $(public) $(bin); fi
104+
cd $(bin); \
105+
for pub in $(public); do \
106+
chmod 755 `basename $$pub`; \
107+
done
108+
- test $(bin) = /bin || rm -f /bin/perl
109+
- test $(bin) = /bin || ln -s $(bin)/perl /bin || cp $(bin)/perl /bin
110+
# chmod 755 makedir
111+
# - makedir `filexp $(lib)`
112+
# - \
113+
#if test `pwd` != `filexp $(lib)`; then \
114+
#cp $(private) `filexp $(lib)`; \
115+
#fi
116+
# cd `filexp $(lib)`; \
117+
#for priv in $(private); do \
118+
#chmod 755 `basename $$priv`; \
119+
#done
120+
- if test `pwd` != $(mansrc); then \
121+
for page in $(manpages); do \
122+
cp $$page $(mansrc)/`basename $$page .man`.$(manext); \
123+
done; \
124+
fi
125+
126+
clean:
127+
rm -f *.o
128+
129+
realclean:
130+
rm -f perl *.orig */*.orig *.o core $(addedbyconf)
131+
132+
# The following lint has practically everything turned on. Unfortunately,
133+
# you have to wade through a lot of mumbo jumbo that can't be suppressed.
134+
# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
135+
# for that spot.
136+
137+
lint:
138+
lint $(lintflags) $(defs) $(c) > perl.fuzz
139+
140+
depend: makedepend
141+
makedepend
142+
143+
test: perl
144+
chmod 755 t/TEST t/base.* t/comp.* t/cmd.* t/io.* t/op.*
145+
cd t && (rm -f perl; ln -s ../perl . || ln ../perl .) && TEST
146+
147+
clist:
148+
echo $(c) | tr ' ' '\012' >.clist
149+
150+
hlist:
151+
echo $(h) | tr ' ' '\012' >.hlist
152+
153+
shlist:
154+
echo $(sh) | tr ' ' '\012' >.shlist
155+
156+
# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
157+
$(obj):
158+
@ echo "You haven't done a "'"make depend" yet!'; exit 1
159+
makedepend: makedepend.SH
160+
/bin/sh makedepend.SH
161+
!NO!SUBS!
162+
$eunicefix Makefile
163+
case `pwd` in
164+
*SH)
165+
$rm -f ../Makefile
166+
ln Makefile ../Makefile
167+
;;
168+
esac

README

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
Perl Kit, Version 1.0
3+
4+
Copyright (c) 1987, Larry Wall
5+
6+
You may copy the perl kit in whole or in part as long as you don't try to
7+
make money off it, or pretend that you wrote it.
8+
--------------------------------------------------------------------------
9+
10+
Perl is a language that combines some of the features of C, sed, awk and shell.
11+
See the manual page for more hype.
12+
13+
Perl will probably not run on machines with a small address space.
14+
15+
Please read all the directions below before you proceed any further, and
16+
then follow them carefully. Failure to do so may void your warranty. :-)
17+
18+
After you have unpacked your kit, you should have all the files listed
19+
in MANIFEST.
20+
21+
Installation
22+
23+
1) Run Configure. This will figure out various things about your system.
24+
Some things Configure will figure out for itself, other things it will
25+
ask you about. It will then proceed to make config.h, config.sh, and
26+
Makefile.
27+
28+
You might possibly have to trim # comments from the front of Configure
29+
if your sh doesn't handle them, but all other # comments will be taken
30+
care of.
31+
32+
(If you don't have sh, you'll have to copy the sample file config.H to
33+
config.h and edit the config.h to reflect your system's peculiarities.)
34+
35+
2) Glance through config.h to make sure system dependencies are correct.
36+
Most of them should have been taken care of by running the Configure script.
37+
38+
If you have any additional changes to make to the C definitions, they
39+
can be done in the Makefile, or in config.h. Bear in mind that they will
40+
get undone next time you run Configure.
41+
42+
3) make depend
43+
44+
This will look for all the includes and modify Makefile accordingly.
45+
Configure will offer to do this for you.
46+
47+
4) make
48+
49+
This will attempt to make perl in the current directory.
50+
51+
5) make test
52+
53+
This will run the regression tests on the perl you just made.
54+
If it doesn't say "All tests successful" then something went wrong.
55+
See the README in the t subdirectory.
56+
57+
6) make install
58+
59+
This will put perl into a public directory (normally /usr/local/bin).
60+
It will also try to put the man pages in a reasonable place. It will not
61+
nroff the man page, however. You may need to be root to do this. If
62+
you are not root, you must own the directories in question and you should
63+
ignore any messages about chown not working.
64+
65+
7) Read the manual entry before running perl.
66+
67+
8) Go down to the x2p directory and do a "make depend, a "make" and a
68+
"make install" to create the awk to perl and sed to perl translators.
69+
70+
9) IMPORTANT! Help save the world! Communicate any problems and suggested
71+
patches to me, lwall@jpl-devvax.jpl.nasa.gov (Larry Wall), so we can
72+
keep the world in sync. If you have a problem, there's someone else
73+
out there who either has had or will have the same problem.
74+
75+
If possible, send in patches such that the patch program will apply them.
76+
Context diffs are the best, then normal diffs. Don't send ed scripts--
77+
I've probably changed my copy since the version you have.
78+
79+
Watch for perl patches in comp.sources.bugs. Patches will generally be
80+
in a form usable by the patch program. If you are just now bringing up
81+
perl and aren't sure how many patches there are, write to me and I'll
82+
send any you don't have. Your current patch level is shown in patchlevel.h.
83+

0 commit comments

Comments
 (0)