Skip to content

Commit

Permalink
a "replacement" for awk and sed
Browse files Browse the repository at this point in the history
[  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.
  • Loading branch information
Larry Wall committed Dec 18, 1987
0 parents commit 8d063cd
Show file tree
Hide file tree
Showing 108 changed files with 20,388 additions and 0 deletions.
1,279 changes: 1,279 additions & 0 deletions Configure

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions EXTERN.h
@@ -0,0 +1,15 @@
/* $Header: EXTERN.h,v 1.0 87/12/18 13:02:26 root Exp $
*
* $Log: EXTERN.h,v $
* Revision 1.0 87/12/18 13:02:26 root
* Initial revision
*
*/

#undef EXT
#define EXT extern

#undef INIT
#define INIT(x)

#undef DOINIT
15 changes: 15 additions & 0 deletions INTERN.h
@@ -0,0 +1,15 @@
/* $Header: INTERN.h,v 1.0 87/12/18 13:02:39 root Exp $
*
* $Log: INTERN.h,v $
* Revision 1.0 87/12/18 13:02:39 root
* Initial revision
*
*/

#undef EXT
#define EXT

#undef INIT
#define INIT(x) = x

#define DOINIT
112 changes: 112 additions & 0 deletions MANIFEST
@@ -0,0 +1,112 @@
After all the perl kits are run you should have the following files:

Filename Kit Description
-------- --- -----------
Configure 6 Run this first
EXTERN.h 10 Included before foreign .h files
INTERN.h 10 Included before domestic .h files
MANIFEST 8 This list of files
Makefile.SH 4 Precursor to Makefile
README 1 The Instructions
Wishlist 10 Some things that may or may not happen
arg.c 3 Expression evaluation
arg.h 8 Public declarations for the above
array.c 6 Numerically subscripted arrays
array.h 10 Public declarations for the above
cmd.c 7 Command interpreter
cmd.h 9 Public declarations for the above
config.H 9 Sample config.h
config.h.SH 9 Produces config.h.
dump.c 8 Debugging output
form.c 8 Format processing
form.h 10 Public declarations for the above
handy.h 10 Handy definitions
hash.c 9 Associative arrays
hash.h 10 Public declarations for the above
makedepend.SH 9 Precursor to makedepend
makedir.SH 10 Precursor to makedir
malloc.c 7 A version of malloc you might not want
patchlevel.h 1 The current patch level of perl
perl.h 9 Global declarations
perl.man.1 5 The manual page(s), first half
perl.man.2 4 The manual page(s), second half
perl.y 5 Yacc grammar for perl
perly.c 2 The perl compiler
search.c 6 String matching
search.h 10 Public declarations for the above
spat.h 10 Search pattern declarations
stab.c 8 Symbol table stuff
stab.h 10 Public declarations for the above
str.c 4 String handling package
str.h 10 Public declarations for the above
t/README 10 Instructions for regression tests
t/TEST 10 The regression tester
t/base.cond 10 See if conditionals work
t/base.if 10 See if if works
t/base.lex 10 See if lexical items work
t/base.pat 10 See if pattern matching works
t/base.term 10 See if various terms work
t/cmd.elsif 10 See if else-if works
t/cmd.for 10 See if for loops work
t/cmd.mod 10 See if statement modifiers work
t/cmd.subval 10 See if subroutine values work
t/cmd.while 7 See if while loops work
t/comp.cmdopt 9 See if command optimization works
t/comp.cpp 10 See if C preprocessor works
t/comp.decl 10 See if declarations work
t/comp.multiline 10 See if multiline strings work
t/comp.script 10 See if script invokation works
t/comp.term 10 See if more terms work
t/io.argv 10 See if ARGV stuff works
t/io.fs 5 See if directory manipulations work
t/io.inplace 10 See if inplace editing works
t/io.print 10 See if print commands work
t/io.tell 10 See if file seeking works
t/op.append 10 See if . works
t/op.auto 9 See if autoincrement et all work
t/op.chop 10 See if chop works
t/op.cond 10 See if conditional expressions work
t/op.crypt 10 See if crypt works
t/op.do 10 See if subroutines work
t/op.each 10 See if associative iterators work
t/op.exec 10 See if exec and system work
t/op.exp 10 See if math functions work
t/op.flip 10 See if range operator works
t/op.fork 10 See if fork works
t/op.goto 10 See if goto works
t/op.int 10 See if int works
t/op.join 10 See if join works
t/op.list 10 See if array lists work
t/op.magic 10 See if magic variables work
t/op.oct 10 See if oct and hex work
t/op.ord 10 See if ord works
t/op.pat 9 See if esoteric patterns work
t/op.push 7 See if push and pop work
t/op.repeat 10 See if x operator works
t/op.sleep 6 See if sleep works
t/op.split 10 See if split works
t/op.sprintf 10 See if sprintf work
t/op.stat 10 See if stat work
t/op.subst 10 See if substitutions work
t/op.time 10 See if time functions work
t/op.unshift 10 See if unshift works
util.c 9 Utility routines
util.h 10 Public declarations for the above
version.c 10 Prints version of perl
x2p/EXTERN.h 10 Same as above
x2p/INTERN.h 10 Same as above
x2p/Makefile.SH 9 Precursor to Makefile
x2p/a2p.h 8 Global declarations
x2p/a2p.man 8 Manual page for awk to perl translator
x2p/a2p.y 8 A yacc grammer for awk
x2p/a2py.c 7 Awk compiler, sort of
x2p/handy.h 10 Handy definitions
x2p/hash.c 9 Associative arrays again
x2p/hash.h 10 Public declarations for the above
x2p/s2p 1 Sed to perl translator
x2p/s2p.man 10 Manual page for sed to perl translator
x2p/str.c 7 String handling package
x2p/str.h 10 Public declarations for the above
x2p/util.c 9 Utility routines
x2p/util.h 10 Public declarations for the above
x2p/walk.c 1 Parse tree walker
168 changes: 168 additions & 0 deletions Makefile.SH
@@ -0,0 +1,168 @@
case $CONFIG in
'')
if test ! -f config.sh; then
ln ../config.sh . || \
ln ../../config.sh . || \
ln ../../../config.sh . || \
(echo "Can't find config.sh."; exit 1)
fi
. config.sh
;;
esac
case "$0" in
*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
esac
echo "Extracting Makefile (with variable substitutions)"
cat >Makefile <<!GROK!THIS!
# $Header: Makefile.SH,v 1.0 87/12/18 16:11:50 root Exp $
#
# $Log: Makefile.SH,v $
# Revision 1.0 87/12/18 16:11:50 root
# Initial revision
#
# Revision 1.0 87/12/18 16:01:07 root
# Initial revision
#
#
CC = $cc
bin = $bin
lib = $lib
mansrc = $mansrc
manext = $manext
CFLAGS = $ccflags -O
LDFLAGS = $ldflags
SMALL = $small
LARGE = $large $split
libs = $libnm -lm
!GROK!THIS!

cat >>Makefile <<'!NO!SUBS!'
public = perl
private =
manpages = perl.man
util =
sh = Makefile.SH makedepend.SH
h1 = EXTERN.h INTERN.h arg.h array.h cmd.h config.h form.h handy.h
h2 = hash.h perl.h search.h spat.h stab.h str.h util.h
h = $(h1) $(h2)
c1 = arg.c array.c cmd.c dump.c form.c hash.c malloc.c
c2 = search.c stab.c str.c util.c version.c
c = $(c1) $(c2)
obj1 = arg.o array.o cmd.o dump.o form.o hash.o malloc.o
obj2 = search.o stab.o str.o util.o version.o
obj = $(obj1) $(obj2)
lintflags = -phbvxac
addedbyconf = Makefile.old bsd eunice filexp loc pdp11 usg v7
# grrr
SHELL = /bin/sh
.c.o:
$(CC) -c $(CFLAGS) $(LARGE) $*.c
all: $(public) $(private) $(util)
touch all
perl: $(obj) perl.o
$(CC) $(LDFLAGS) $(LARGE) $(obj) perl.o $(libs) -o perl
perl.c: perl.y
@ echo Expect 2 shift/reduce errors...
yacc perl.y
mv y.tab.c perl.c
perl.o: perl.c perly.c perl.h EXTERN.h search.h util.h INTERN.h handy.h
$(CC) -c $(CFLAGS) $(LARGE) perl.c
# if a .h file depends on another .h file...
$(h):
touch $@
perl.man: perl.man.1 perl.man.2
cat perl.man.1 perl.man.2 >perl.man
install: perl perl.man
# won't work with csh
export PATH || exit 1
- mv $(bin)/perl $(bin)/perl.old
- if test `pwd` != $(bin); then cp $(public) $(bin); fi
cd $(bin); \
for pub in $(public); do \
chmod 755 `basename $$pub`; \
done
- test $(bin) = /bin || rm -f /bin/perl
- test $(bin) = /bin || ln -s $(bin)/perl /bin || cp $(bin)/perl /bin
# chmod 755 makedir
# - makedir `filexp $(lib)`
# - \
#if test `pwd` != `filexp $(lib)`; then \
#cp $(private) `filexp $(lib)`; \
#fi
# cd `filexp $(lib)`; \
#for priv in $(private); do \
#chmod 755 `basename $$priv`; \
#done
- if test `pwd` != $(mansrc); then \
for page in $(manpages); do \
cp $$page $(mansrc)/`basename $$page .man`.$(manext); \
done; \
fi
clean:
rm -f *.o
realclean:
rm -f perl *.orig */*.orig *.o core $(addedbyconf)
# The following lint has practically everything turned on. Unfortunately,
# you have to wade through a lot of mumbo jumbo that can't be suppressed.
# If the source file has a /*NOSTRICT*/ somewhere, ignore the lint message
# for that spot.
lint:
lint $(lintflags) $(defs) $(c) > perl.fuzz
depend: makedepend
makedepend
test: perl
chmod 755 t/TEST t/base.* t/comp.* t/cmd.* t/io.* t/op.*
cd t && (rm -f perl; ln -s ../perl . || ln ../perl .) && TEST
clist:
echo $(c) | tr ' ' '\012' >.clist
hlist:
echo $(h) | tr ' ' '\012' >.hlist
shlist:
echo $(sh) | tr ' ' '\012' >.shlist
# AUTOMATICALLY GENERATED MAKE DEPENDENCIES--PUT NOTHING BELOW THIS LINE
$(obj):
@ echo "You haven't done a "'"make depend" yet!'; exit 1
makedepend: makedepend.SH
/bin/sh makedepend.SH
!NO!SUBS!
$eunicefix Makefile
case `pwd` in
*SH)
$rm -f ../Makefile
ln Makefile ../Makefile
;;
esac
83 changes: 83 additions & 0 deletions README
@@ -0,0 +1,83 @@

Perl Kit, Version 1.0

Copyright (c) 1987, Larry Wall

You may copy the perl kit in whole or in part as long as you don't try to
make money off it, or pretend that you wrote it.
--------------------------------------------------------------------------

Perl is a language that combines some of the features of C, sed, awk and shell.
See the manual page for more hype.

Perl will probably not run on machines with a small address space.

Please read all the directions below before you proceed any further, and
then follow them carefully. Failure to do so may void your warranty. :-)

After you have unpacked your kit, you should have all the files listed
in MANIFEST.

Installation

1) Run Configure. This will figure out various things about your system.
Some things Configure will figure out for itself, other things it will
ask you about. It will then proceed to make config.h, config.sh, and
Makefile.

You might possibly have to trim # comments from the front of Configure
if your sh doesn't handle them, but all other # comments will be taken
care of.

(If you don't have sh, you'll have to copy the sample file config.H to
config.h and edit the config.h to reflect your system's peculiarities.)

2) Glance through config.h to make sure system dependencies are correct.
Most of them should have been taken care of by running the Configure script.

If you have any additional changes to make to the C definitions, they
can be done in the Makefile, or in config.h. Bear in mind that they will
get undone next time you run Configure.

3) make depend

This will look for all the includes and modify Makefile accordingly.
Configure will offer to do this for you.

4) make

This will attempt to make perl in the current directory.

5) make test

This will run the regression tests on the perl you just made.
If it doesn't say "All tests successful" then something went wrong.
See the README in the t subdirectory.

6) make install

This will put perl into a public directory (normally /usr/local/bin).
It will also try to put the man pages in a reasonable place. It will not
nroff the man page, however. You may need to be root to do this. If
you are not root, you must own the directories in question and you should
ignore any messages about chown not working.

7) Read the manual entry before running perl.

8) Go down to the x2p directory and do a "make depend, a "make" and a
"make install" to create the awk to perl and sed to perl translators.

9) IMPORTANT! Help save the world! Communicate any problems and suggested
patches to me, lwall@jpl-devvax.jpl.nasa.gov (Larry Wall), so we can
keep the world in sync. If you have a problem, there's someone else
out there who either has had or will have the same problem.

If possible, send in patches such that the patch program will apply them.
Context diffs are the best, then normal diffs. Don't send ed scripts--
I've probably changed my copy since the version you have.

Watch for perl patches in comp.sources.bugs. Patches will generally be
in a form usable by the patch program. If you are just now bringing up
perl and aren't sure how many patches there are, write to me and I'll
send any you don't have. Your current patch level is shown in patchlevel.h.

0 comments on commit 8d063cd

Please sign in to comment.