Scripting Languages Awk

Total Page:16

File Type:pdf, Size:1020Kb

Scripting Languages Awk Scripting Languages Awk Higher-level languages. Named for its three developers: Scripting Languages More compact for small programs. Alfred Aho COMS W4115 Often not suitable for large systems. Peter Weinberger Brian Kernighan Prof. Stephen A. Edwards The more popular ones: Fall 2004 Awk Good for data file manipulation. I use it for computing Columbia University grades and other simple tasks. Perl Department of Computer Science Python Tcl Bourne Shell Simple Awk Program Simple Awk Program Awk Program Structure Input file. Each line a record. Space-separated fields: Beth 10.0 0 pattern { action } employee, pay rate, hours worked Kathy 14.0 10 pattern { action } Beth 10.0 0 . Dan 9.75 0 3rd field . Kathy 14.0 10 z}|{ $3 > 0 { print $1, $2 * $3 } awk scans an input file one line at a time and, in order, Mark 10.0 20 | {z } | {z } Susie 8.25 18 runs each action whose pattern matches. pattern action Run on the awk program Patterns: Kathy 140 BEGIN, END True before and after the file. $3 > 0 { print $1, $2 * $3 } expression Condition produces /regular expression/ String pattern match pattern && pattern Kathy 140 pattern || pattern Boolean operators Mark 200 ! Susie 148.5 pattern Awk One-Liners Statistics in Awk Associative Arrays: Word Counter Print every line #!/bin/awk -f { gsub(/[.,:;!(){}]/, "") # remove punctuation BEGIN { n = 0; s = 0; ss = 0;} for ( i = 1 ; i <= NF ; i++ ) { print } NF == 1 { n++; s += $1; ss += $1 * $1; } count[$i]++ } Print the first and third fields of each line END { print n " data points" END { for (w in count) { print $1, $3 } m = (s+0.0) / n; print m " average" print count[w], w | "sort -rn" } sd = sqrt( (ss - n * m * m) / ( n - 1.0)) Print every line with three fields print sd " standard deviation" Run on the Tiger reference manual produces } NF == 3 { print } 103 the 1 58 of 5 51 is 6 data points Print a line number before every line 10 49 and Run on gives 6.16667 average 49 a 3 3.92003 standard deviation 35 expression { print NR, $0 } 7 32 The 11 29 = Perl Wordcount in Perl Understandable wordcount in Perl Larry Wall’s #!/usr/bin/perl #!/usr/bin/perl Practical Extraction and Report Language while(<>) { while($line = <>) { or chop; chop($line); s/[.,:;!(){}]//g; $line =˜ s/[.,:;!(){}]//g; Pathologically Eclectic Rubbish Lister @words = split; @words = split(/\s+/, $line); Larger, more flexible language than Awk. Good for text foreach (@words) { foreach $word (@words) { processing and other tasks. Strange semantics. Henious $count{$_}++; $count{$word}++; syntax. } } } } Excellent regular-expression support. More complicated open(SORTER, "| sort -nr"); open(SORTER, "| sort -nr"); data structures possible (even classes). foreach (keys %count) { foreach $word (keys %count) { print SORTER print SORTER $count{$_}, " ", $_,"\n"; $count{$word}, " ", $word,"\n"; } } “There’s more than one way to do it” So Why Perl? Python Perhaps too many. Equivalent ways to print STDIN: Perhaps the most popular scripting language. Perl designed by a sane man. while (<STDIN>) { print; } Despite its flaws, it’s very powerful. Very clean syntax and semantics. print while <STDIN> print while <> Almost has a good type system. Large collection of libraries (but not as big as Perl’s). while (defined(($_ = <STDIN>)) { print $_; } Very few things can't be done in Perl. for (;<STDIN>;) { print; } Regular expression support (but not as integrated as print $_ while defined($_ = <STDIN>); Fast, flexible interpreter. Perl’s.) Many Perl statements come in prefix and postfix form Ability to make virtually every Unix system call. Binary while (...) ... data manipulation. ... while ... Ported everywhere. if (...) ... Very, very extensive collection of libraries. Database ... if ... access. CGI/HTML for the web. Math. IPC. Time. ... unless ... Wordcount in Python Python Classes Python’s Merits #!/usr/bin/env python class Complex: Good support for programming-in-the-large: def __init__(self, realpart, imagpart): self.r = realpart Packages with separate namespaces; Exceptions; import fileinput, re, string, os self.i = imagpart Classes def add(self, a): count = {} self.r = self.r + a.r for line in fileinput.input(): self.i = self.i + a.i Persistent datastructures (pickling) line = re.sub(r’[.,:;!(){}]’,"",line) def p(self): High-level: lists, strings, associative arrays, iterators for word in string.split(line): print "%g + %gi" % (self.r,self.i) if not count.has_key(word): Good collection of libraries: count[word] = 1 x = Complex(1,2) y = Complex(2,3) else: x.p() Operating-system access (files, directories, etc.); count[word] = count[word] + 1 x.add(y) x.p() String manipulation; Curses; Databases; Networking (CGI, HTTP, URL, mail/Mime, HTML); Tk; f = os.popen("sort -nr",’w’) Prints for word in count.keys(): Cryptography; System-specific (Windows, Mac, SGI, f.write(’%d %s\n’ % (count[word], word) ) 1 + 2i 3 + 5i POSIX) Python vs. Perl Tcl Tcl Syntax Python can be the more verbose language, but Perl can John Ousterhout’s Tool Command Language was Shell-like command syntax: be cryptic. originally intended to be grafted on to an application to command argument argument . make it controllable. Regular expression support more integrated with All data is strings (incl. numbers and lists) language in Perl. Since become a general-purpose scripting language. Its Macro-like variable substitution: syntax is quite simple, although rather atypical for a Perl better-known. programming language. set foo "123 abc" Probably comparable execution speeds. bar 1 $foo 3 Tk, a Tcl package, provide graphical user interface More “tricks” possible in Perl; Python more disciplined. widgets. Tcl/Tk may be the easiest way to write a GUI. Command substitution: Python has the much cleaner syntax and semantics; I Tk has been connected to Perl and Python as well. set foo 1 know which language’s programs I’d rather maintain. set bar 2 puts [eval $foo + $bar]; # Print 3 Wordcount in Tcl Nifty Tcl Features Tk #!/usr/bin/env tclsh Associative arrays “Hello World” in Tk. while {[gets stdin line] >= 0} { set count(Stephen) 1 button .b -text "Hello World" -command "exit" regsub -all {[.,:;!(){}]} $line "" line pack .b foreach word $line { Lists if {![info exists count($word)]} { set count($word) 1 lappend foo 1 } else { incr count($word) lappend foo 2 } foreach i $foo { puts $i } ; # print 1 then 2 } } Procedures set f [open "| sort -rn" w] proc sum3 {a b c} { foreach word [array names count] { return [expr $a + $b + $c] puts $f "$count($word) $word" } } An Editable Graph An Editable Graph An Editable Graph # Set up the main window # Set up bottom control buttons set w .plot frame $w.buttons catch destroy $w pack $w.buttons -side bottom -fill x -pady 2m toplevel $w button $w.buttons.dismiss -text Dismiss -command "destroy $w" wm title $w "Plot Demonstration" button $w.buttons.code -text "See Code" -command "showCode $w" pack $w.buttons.dismiss $w.buttons.code -side left -expand 1 wm iconname $w "Plot" positionWindow $w # Set up graph itself set c $w.c canvas $c -relief raised -width 450 -height 300 pack $w.c -side top -fill x # Text description at top label $w.msg -font $font -wraplength 4i -justify left \ # Draw axes -text "This window displays a canvas widget containing set plotFont Helvetica 18 $c create line 100 250 400 250 -width 2 a simple 2-dimensional plot. You can doctor the data $c create line 100 250 100 50 -width 2 by dragging any of the points with mouse button 1." $c create text 225 20 -text "A Simple Plot" -font $plotFont \ pack $w.msg -side top -fill brown An Editable Graph An Editable Graph Bourne Shell # Draw axis labels # Bind actions to events Default shell on most Unix systems (sh or bash). for {set i 0} {$i <= 10} {incr i} { $c bind point <Any-Enter> "$c itemconfig current -fill red" set x [expr {100 + ($i*30)}] $c bind point <Any-Leave> "$c itemconfig current -fill SkyBlue2" $c create line $x 250 $x 245 -width 2 $c bind point <1> "plotDown $c %x %y" Good for writing “shell scripts:” parsing command-line $c create text $x 254 -text [expr 10*$i] \ $c bind point <ButtonRelease-1> "$c dtag selected" -anchor n -font $plotFont bind $c <B1-Motion> "plotMove $c %x %y" arguments, invoking and controlling other commands, etc. } set plot(lastX) 0 for {set i 0} {$i <= 5} {incr i} { set plot(lastY) 0 Example: The cc command. set y [expr {250 - ($i*40)}] proc plotDown {w x y} { # Called when point clicked $c create line 100 $y 105 $y -width 2 global plot $c create text 96 $y -text [expr $i*50].0 \ $w dtag selected Most C compilers built from four pieces: -anchor e -font $plotFont $w addtag selected withtag current } $w raise current Preprocessor (cpp) # Draw points set plot(lastX) $x foreach point {{12 56} {20 94} {33 98} {32 120} {61 180} set plot(lastY) $y {75 160} {98 223}} { } Actual compiler (cc1) set x [expr {100 + (3*[lindex $point 0])}] proc plotMove {w x y} { # Called when point dragged set y [expr {250 - (4*[lindex $point 1])/5}] global plot set item [$c create oval [expr $x-6] [expr $y-6] \ $w move selected [expr $x-$plot(lastX)] \ Assembler (as) [expr $x+6] [expr $y+6] -width 1 -outline black \ [expr $y-$plot(lastY)] -fill SkyBlue2] set plot(lastX) $x Linker (ld) $c addtag point withtag $item set plot(lastY) $y } } cc in sh cc in sh cc in sh #!/bin/sh # Parse command-line options # Parse ®lenames while [ ! -z "$1" ]; while [ ! -z "$1" ]; do # Set up command names do case x"$1" in case x"$1" in root=/usr/lib x-v) echo "Stephen's cc 1.0"; exit 0 ;; x-o) shift; outfile=$1 ;; x*.c) cfiles="$cfiles $1" ;; cpp=$root/cpp x-c) stopafterassemble=1 ;; x*.s) sfiles="$sfiles $1" ;; cc1=$root/cc1
Recommended publications
  • CRN What It Was Doing and Why It Was Cognitive Systems Vision Doing It, and to Recover from Mental Continued on Page 8 Expanding the Pipeline
    COMPUTING RESEARCH NEWS Computing Research Association, Celebrating 30 Years of Service to the Computing Research Community November 2002 Vol. 14/No. 5 DARPA’s New Cognitive Systems Vision By Ron Brachman and IPTO’s goal is to create a new to cope with systems both keep Zachary Lemnios generation of cognitive systems. growing. In order to make our systems more reliable, more secure, The impact of the Defense Mired in Moore’s Law? and more understandable, and to Advanced Research Projects Agency One benefit of such cognitive continue making substantial contri- (DARPA) on computing over the systems would be their help in butions to society, we need to do past 40 years has been profound. Led extracting us from a corner into something dramatically different. by the visionary J.C.R. Licklider and which our success seems to have his innovative successors in the painted us. The research that has The Promise of Cognitive Information Processing Techniques helped the industry follow Moore’s Systems Office (IPTO), DARPA initiated “Law” has created processors that are IPTO is attacking this problem by work that ultimately put personal remarkably fast and small, and data driving a fundamental change in computers on millions of desktops storage capabilities that are vast and computing systems. By giving systems Ron Brachman and made the global Internet a cheap. Unfortunately, these incred- more cognitive capabilities, we reality. In fact, the original IPTO, ible developments have cut two ways. believe we can make them more which lasted from 1962 to 1985, was While today’s computers are more responsible for their own behavior in large part responsible for estab- powerful than ever, we have been and maintenance.
    [Show full text]
  • Use Perl Regular Expressions in SAS® Shuguang Zhang, WRDS, Philadelphia, PA
    NESUG 2007 Programming Beyond the Basics Use Perl Regular Expressions in SAS® Shuguang Zhang, WRDS, Philadelphia, PA ABSTRACT Regular Expression (Regexp) enhance search and replace operations on text. In SAS®, the INDEX, SCAN and SUBSTR functions along with concatenation (||) can be used for simple search and replace operations on static text. These functions lack flexibility and make searching dynamic text difficult, and involve more function calls. Regexp combines most, if not all, of these steps into one expression. This makes code less error prone, easier to maintain, clearer, and can improve performance. This paper will discuss three ways to use Perl Regular Expression in SAS: 1. Use SAS PRX functions; 2. Use Perl Regular Expression with filename statement through a PIPE such as ‘Filename fileref PIPE 'Perl programm'; 3. Use an X command such as ‘X Perl_program’; Three typical uses of regular expressions will also be discussed and example(s) will be presented for each: 1. Test for a pattern of characters within a string; 2. Replace text; 3. Extract a substring. INTRODUCTION Perl is short for “Practical Extraction and Report Language". Larry Wall Created Perl in mid-1980s when he was trying to produce some reports from a Usenet-Nes-like hierarchy of files. Perl tries to fill the gap between low-level programming and high-level programming and it is easy, nearly unlimited, and fast. A regular expression, often called a pattern in Perl, is a template that either matches or does not match a given string. That is, there are an infinite number of possible text strings.
    [Show full text]
  • A First Course to Openfoam
    Basic Shell Scripting Slides from Wei Feinstein HPC User Services LSU HPC & LON [email protected] September 2018 Outline • Introduction to Linux Shell • Shell Scripting Basics • Variables/Special Characters • Arithmetic Operations • Arrays • Beyond Basic Shell Scripting – Flow Control – Functions • Advanced Text Processing Commands (grep, sed, awk) Basic Shell Scripting 2 Linux System Architecture Basic Shell Scripting 3 Linux Shell What is a Shell ▪ An application running on top of the kernel and provides a command line interface to the system ▪ Process user’s commands, gather input from user and execute programs ▪ Types of shell with varied features o sh o csh o ksh o bash o tcsh Basic Shell Scripting 4 Shell Comparison Software sh csh ksh bash tcsh Programming language y y y y y Shell variables y y y y y Command alias n y y y y Command history n y y y y Filename autocompletion n y* y* y y Command line editing n n y* y y Job control n y y y y *: not by default http://www.cis.rit.edu/class/simg211/unixintro/Shell.html Basic Shell Scripting 5 What can you do with a shell? ▪ Check the current shell ▪ echo $SHELL ▪ List available shells on the system ▪ cat /etc/shells ▪ Change to another shell ▪ csh ▪ Date ▪ date ▪ wget: get online files ▪ wget https://ftp.gnu.org/gnu/gcc/gcc-7.1.0/gcc-7.1.0.tar.gz ▪ Compile and run applications ▪ gcc hello.c –o hello ▪ ./hello ▪ What we need to learn today? o Automation of an entire script of commands! o Use the shell script to run jobs – Write job scripts Basic Shell Scripting 6 Shell Scripting ▪ Script: a program written for a software environment to automate execution of tasks ▪ A series of shell commands put together in a file ▪ When the script is executed, those commands will be executed one line at a time automatically ▪ Shell script is interpreted, not compiled.
    [Show full text]
  • Shell Scripting, Scripting Examples
    Last Time… on the website Lecture 6 Shell Scripting What is a shell? • The user interface to the operating system • Functionality: – Execute other programs – Manage files – Manage processes • Full programming language • A program like any other – This is why there are so many shells Shell History • There are many choices for shells • Shell features evolved as UNIX grew Most Commonly Used Shells – /bin/csh C shell – /bin/tcsh Enhanced C Shell – /bin/sh The Bourne Shell / POSIX shell – /bin/ksh Korn shell – /bin/bash Korn shell clone, from GNU Ways to use the shell • Interactively – When you log in, you interactively use the shell • Scripting – A set of shell commands that constitute an executable program Review: UNIX Programs • Means of input: – Program arguments [control information] – Environment variables [state information] – Standard input [data] • Means of output: – Return status code [control information] – Standard out [data] – Standard error [error messages] Shell Scripts • A shell script is a regular text file that contains shell or UNIX commands – Before running it, it must have execute permission: • chmod +x filename • A script can be invoked as: – ksh name [ arg … ] – ksh < name [ args … ] – name [ arg …] Shell Scripts • When a script is run, the kernel determines which shell it is written for by examining the first line of the script – If 1st line starts with #!pathname-of-shell, then it invokes pathname and sends the script as an argument to be interpreted – If #! is not specified, the current shell assumes it is a script in its own language • leads to problems Simple Example #!/bin/sh echo Hello World Scripting vs.
    [Show full text]
  • Unix (And Linux)
    AWK....................................................................................................................................4 BC .....................................................................................................................................11 CHGRP .............................................................................................................................16 CHMOD.............................................................................................................................19 CHOWN ............................................................................................................................26 CP .....................................................................................................................................29 CRON................................................................................................................................34 CSH...................................................................................................................................36 CUT...................................................................................................................................71 DATE ................................................................................................................................75 DF .....................................................................................................................................79 DIFF ..................................................................................................................................84
    [Show full text]
  • Chapter 10 SHELL Substitution and I/O Operations
    Chapter 10 SHELL Substitution and I/O Operations 10.1 Command Substitution Command substitution is the mechanism by which the shell performs a given set of commands and then substitutes their output in the place of the commands. Syntax: The command substitution is performed when a command is given as: `command` When performing command substitution make sure that you are using the backquote, not the single quote character. Example: Command substitution is generally used to assign the output of a command to a variable. Each of the following examples demonstrate command substitution: #!/bin/bash DATE=`date` echo "Date is $DATE" USERS=`who | wc -l` echo "Logged in user are $USERS" UP=`date ; uptime` echo "Uptime is $UP" This will produce following result: Date is Thu Jul 2 03:59:57 MST 2009 Logged in user are 1 Uptime is Thu Jul 2 03:59:57 MST 2009 03:59:57 up 20 days, 14:03, 1 user, load avg: 0.13, 0.07, 0.15 10.2 Shell Input/Output Redirections Most Unix system commands take input from your terminal and send the resulting output back to your terminal. A command normally reads its input from a place called standard input, which happens to be your terminal by default. Similarly, a command normally writes its output to standard output, which is also your terminal by default. Output Redirection: The output from a command normally intended for standard output can be easily diverted to a file instead. This capability is known as output redirection: If the notation > file is appended to any command that normally writes its output to standard output, the output of that command will be written to file instead of your terminal: Check following who command which would redirect complete output of the command in users file.
    [Show full text]
  • Bash Guide for Beginners
    Bash Guide for Beginners Machtelt Garrels Garrels BVBA <tille wants no spam _at_ garrels dot be> Version 1.11 Last updated 20081227 Edition Bash Guide for Beginners Table of Contents Introduction.........................................................................................................................................................1 1. Why this guide?...................................................................................................................................1 2. Who should read this book?.................................................................................................................1 3. New versions, translations and availability.........................................................................................2 4. Revision History..................................................................................................................................2 5. Contributions.......................................................................................................................................3 6. Feedback..............................................................................................................................................3 7. Copyright information.........................................................................................................................3 8. What do you need?...............................................................................................................................4 9. Conventions used in this
    [Show full text]
  • The AWK Programming Language
    The Programming ~" ·. Language PolyAWK- The Toolbox Language· Auru:o V. AHo BRIAN W.I<ERNIGHAN PETER J. WEINBERGER TheAWK4 Programming~ Language TheAWI(. Programming~ Language ALFRED V. AHo BRIAN w. KERNIGHAN PETER J. WEINBERGER AT& T Bell Laboratories Murray Hill, New Jersey A ADDISON-WESLEY•• PUBLISHING COMPANY Reading, Massachusetts • Menlo Park, California • New York Don Mills, Ontario • Wokingham, England • Amsterdam • Bonn Sydney • Singapore • Tokyo • Madrid • Bogota Santiago • San Juan This book is in the Addison-Wesley Series in Computer Science Michael A. Harrison Consulting Editor Library of Congress Cataloging-in-Publication Data Aho, Alfred V. The AWK programming language. Includes index. I. AWK (Computer program language) I. Kernighan, Brian W. II. Weinberger, Peter J. III. Title. QA76.73.A95A35 1988 005.13'3 87-17566 ISBN 0-201-07981-X This book was typeset in Times Roman and Courier by the authors, using an Autologic APS-5 phototypesetter and a DEC VAX 8550 running the 9th Edition of the UNIX~ operating system. -~- ATs.T Copyright c 1988 by Bell Telephone Laboratories, Incorporated. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopy­ ing, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Published simultaneously in Canada. UNIX is a registered trademark of AT&T. DEFGHIJ-AL-898 PREFACE Computer users spend a lot of time doing simple, mechanical data manipula­ tion - changing the format of data, checking its validity, finding items with some property, adding up numbers, printing reports, and the like.
    [Show full text]
  • Introduction to Perl
    Introduction to Perl Science and Technology Support Group High Performance Computing Ohio Supercomputer Center 1224 Kinnear Road Columbus, OH 43212-1163 Introduction to Perl • Setting the Stage • Functions • Data Types • Exercises 3 • Operators • File and Directory Manipulation • Exercises 1 • External Processes • Control Structures • References • Basic I/O • Exercises 4 • Exercises 2 • Some Other Topics of Interest • Regular Expressions • For Further Information 2 Introduction to Perl Setting the Stage • What is Perl? • How to get Perl • Basic Concepts 3 Introduction to Perl What is Perl? • Practical Extraction and Report Language –Or: Pathologically Eclectic Rubbish Lister • Created by Larry Wall • A compiled/interpreted programming language • Combines popular features of the shell, sed, awk and C • Useful for manipulating files, text and processes – Also for sysadmins and CGI • Latest official version is 5.005 – Perl 4.036 still in widespread use –Use perl -v to see the version • Perl is portable •Perlis free! 4 Introduction to Perl How to Get Perl • Perl’s most natural “habitat” is UNIX • Has been ported to most other systems as well – MS Windows, Macintosh, VMS, OS/2, Amiga… • Available for free under the GNU Public License – Basically says you can only distribute binaries of Perl if you also make the source code available, including the source to any modifications you may have made • Can download source code (C) and compile yourself (unlikely to be necessary) • Pre-compiled binaries also available for most systems • Support available
    [Show full text]
  • A Crash Course on UNIX
    AA CCrraasshh CCoouurrssee oonn UUNNIIXX UNIX is an "operating system". Interface between user and data stored on computer. A Windows-style interface is not required. Many flavors of UNIX (and windows interfaces). Solaris, Mandrake, RedHat (fvwm, Gnome, KDE), ... Most UNIX users use "shells" (or "xterms"). UNIX windows systems do provide some Microsoft Windows functionality. TThhee SShheellll A shell is a command-line interface to UNIX. Also many flavors, e.g. sh, bash, csh, tcsh. The shell provides commands and functionality beyond the basic UNIX tools. E.g., wildcards, shell variables, loop control, etc. For this tutorial, examples use tcsh in RedHat Linux running Gnome. Differences are minor for the most part... BBaassiicc CCoommmmaannddss You need these to survive: ls, cd, cp, mkdir, mv. Typically these are UNIX (not shell) commands. They are actually programs that someone has written. Most commands such as these accept (or require) "arguments". E.g. ls -a [show all files, incl. "dot files"] mkdir ASTR688 [create a directory] cp myfile backup [copy a file] See the handout for a list of more commands. AA WWoorrdd AAbboouutt DDiirreeccttoorriieess Use cd to change directories. By default you start in your home directory. E.g. /home/dcr Handy abbreviations: Home directory: ~ Someone else's home directory: ~user Current directory: . Parent directory: .. SShhoorrttccuuttss To return to your home directory: cd To return to the previous directory: cd - In tcsh, with filename completion (on by default): Press TAB to complete filenames as you type. Press Ctrl-D to print a list of filenames matching what you have typed so far. Completion works with commands and variables too! Use ↑, ↓, Ctrl-A, & Ctrl-E to edit previous lines.
    [Show full text]
  • Sensory Information Processing (1 January 1976
    Im plem enting Functional Program s Using M utable Abstract Data Types Ganesh C. Gopalakrishnan, Department of Computer Science, Univ. of Utah, Salt Lake City, Utah 84112 and Mandayam K. Srivas, Department of Computer Science, SUNY, Stony Brook, N Y 11794 W e study the following problem in this paper. Suppose we have a purely functional program that uses a set of abstract data types by invoking their operations. Is there an order of evaluation of the operations in the program that preserves the applicative order of evaluation semantics of the program even when the abstract data types behave as mutable modules. An abstract data type is mutable if one of its operations destructively updates the object rather than returning a new object as a result. This problem is important for several reasons. It can help eliminate unnecessary copying of data structure states. It supports a methodology in which one can program in a purely functional notation for purposes of verification and clarity, and then automatically transform the program into one in an object oriented, imperative language, such as CLU, A D A , Smalltalk, etc., that supports abstract data types. It allows accruing both the benefits of using abstract data types in programming, and allows modularity and verifiability. Keywords: Functional Program Implementation, Mutable Modules, Abstract Data Types, Syntactic Conditions. C o n t e n t s 1 Introduction 1 1.1 Related W o r k ........................................................................................................................... 2 1.2 Terminology, Assumptions, and Problem Statement............................................... 2 2 Syntactic Characterization of In Situ Evaluability 3 2.1 Syntactic Conditions for Straight-line Expressions..................................................
    [Show full text]
  • Minimal Perl for UNIX and Linux People
    Minimal Perl For UNIX and Linux People BY TIM MAHER MANNING Greenwich (74° w. long.) For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. Cherokee Station PO Box 20386 Fax: (609) 877-8256 New York, NY 10021 email: [email protected] ©2007 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Copyeditor: Tiffany Taylor 209 Bruce Park Avenue Typesetters: Denis Dalinnik, Dottie Marsico Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1-932394-50-8 Printed in the United States of America 12345678910–VHG–1009080706 To Yeshe Dolma Sherpa, whose fortitude, endurance, and many sacrifices made this book possible. To my parents, Gloria Grady Washington and William N. Maher, who indulged my early interests in literature. To my limbic system, with gratitude for all the good times we’ve had together.
    [Show full text]