Description *********** "Perl" is an 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. Unlike most Unix utilities, *perl* does not arbitrarily limit the size of your data--if you've got the memory, *perl* can slurp in your whole file as a single string. Recursion is of unlimited depth. And the hash tables used by associative arrays grow as necessary to prevent degraded performance. *Perl* uses sophisticated pattern matching techniques to scan large amounts of data very quickly. Although optimized for scanning text, *perl* can also deal with binary data, and can make dbm files look like associative arrays (where dbm is available). Setuid *perl* scripts are safer than C programs through a dataflow tracing mechanism which prevents many stupid security holes. 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. OK, enough hype. File: perl.info, Node: Perl Startup, Next: Data Types, Prev: Preface, Up: Top Perl Startup ************ Upon startup, *perl* looks for your script in one of the following places: 1. Specified line by line via `-e' switches on the command line. 2. Contained in the file specified by the first filename on the command line. (Note that systems supporting the `#!' notation invoke interpreters this way.) 3. Passed in implicitly via standard input. This only works if there are no filename arguments--to pass arguments to a `stdin' script you must explicitly specify a `-' for the script name. After locating your script, *perl* compiles it to an internal form. If the script is syntactically correct, it is executed. * Menu: * Options:: Command line options. File: perl.info, Node: Options, Up: Perl Startup Options ======= Note: on first reading this section may not make much sense to you. It's here at the front for easy reference. A single-character option may be combined with the following option, if any. This is particularly useful when invoking a script using the `#!' construct which only allows one argument. Example: #!/usr/bin/perl -spi.bak # same as -s -p -i.bak ... Options include: `-0 digits' specifies the record separator ($/) as an octal number. If there are no digits, the null character is the separator. Other switches may precede or follow the digits. For example, if you have a version of `find' which can print filenames terminated by the null character, you can say this: find . -name '*.bak' -print0 | perl -n0e unlink The special value `00' will cause Perl to slurp files in paragraph mode. The value `0777' will cause Perl to slurp files whole since there is no legal character with that value. `-a' turns on autosplit mode when used with a `-n' or `-p'. An implicit split command to the `@F' array is done as the first thing inside the implicit while loop produced by the `-n' or `-p'. perl -ane 'print pop(@F), "\n";' is equivalent to while (<>) { @F = split(' '); print pop(@F), "\n"; } `-c' causes *perl* to check the syntax of the script and then exit without executing it. `-d' runs the script under the perl debugger. *Note Debugging::, for more info. `-D number' sets debugging flags. To watch how it executes your script, use `-D14'. (This only works if debugging is compiled into your *perl*.) Another nice value is `-D1024', which lists your compiled syntax tree. And `-D512' displays compiled regular expressions. `-e commandline' may be used to enter one line of script. Multiple `-e' commands may be given to build up a multi-line script. If `-e' is given, *perl* will not look for a script filename in the argument list. `-i extension' specifies that files processed by the `<>' construct are to be edited in-place. It does this by renaming the input file, opening the output file by the same name, and selecting that output file as the default for print statements. The extension, if supplied, is added to the name of the old file to make a backup copy. If no extension is supplied, no backup is made. Saying perl -p -i.bak -e "s/foo/bar/;" ... is the same as using the script: #!/usr/bin/perl -pi.bak s/foo/bar/; which is equivalent to #!/usr/bin/perl while (<>) { if ($ARGV ne $oldargv) { rename($ARGV, $ARGV . '.bak'); open(ARGVOUT, ">$ARGV"); select(ARGVOUT); $oldargv = $ARGV; } s/foo/bar/; } continue { print; # this prints to original filename } select(STDOUT); except that the `-i' form doesn't need to compare `$ARGV' to `$oldargv' to know when the filename has changed. It does, however, use `ARGVOUT' for the selected filehandle. Note that `STDOUT' is restored as the default output filehandle after the loop. You can use `eof' to locate the end of each input file, in case you want to append to each file, or reset line numbering (*Note Input/Output::, for an example). `-I directory' may be used in conjunction with `-P' to tell the C preprocessor where to look for include files. By default `/usr/include' and `/usr/lib/perl' are searched. `-l octnum' enables automatic line-ending processing. It has two effects: first, it automatically chops the line terminator when used with `-n' or `-p', and second, it assigns `$\' to have the value of OCTNUM so that any print statements will have that line terminator added back on. If OCTNUM is omitted, sets `$\' to the current value of `$/'. For instance, to trim lines to 80 columns: perl -lpe 'substr($_, 80) = ""' Note that the assignment `$\ = $/' is done when the switch is processed, so the input record separator can be different than the output record separator if the `-l' switch is followed by a `-0' switch: gnufind / -print0 | perl -ln0e 'print "found $_" if -p' This sets `$\' to newline and then sets `$/' to the null character. `-n' causes *perl* to assume the following loop around your script, which makes it iterate over filename arguments somewhat like `sed -n' or `awk': while (<>) { ... # your script goes here } Note that the lines are *not* printed by default. See `-p' option to have lines printed. Here is an efficient way to delete all files older than a week: [ before version 4.003 ] find . -mtime +7 -print | perl -ne 'chop;unlink;' [ version 4.003 and beyond ] find . -mtime +7 -print | perl -nle 'unlink;' This is faster than using the `-exec' switch of find because you don't have to start a process on every filename found. `-p' causes *perl* to assume the following loop around your script, which makes it iterate over filename arguments somewhat like `sed': while (<>) { ... # your script goes here } continue { print; } Note that the lines are printed automatically. To suppress printing use the `-n' switch. A `-p' overrides a `-n' switch. `-P' causes your script to be run through the C preprocessor before compilation by *perl*. (Since both comments and cpp directives begin with the `#' character, you should avoid starting comments with any words recognized by the C preprocessor such as `if', `else' or `define'.) `-s' enables some rudimentary switch parsing for switches on the command line after the script name but before any filename arguments (or before a `--'). Any switch found there is removed from `@ARGV' and sets the corresponding variable in the *perl* script. The following script prints `true' if and only if the script is invoked with a `-xyz' switch. #!/usr/bin/perl -s if ($xyz) { print "true\n"; } `-S' makes *perl* use the `PATH' environment variable to search for the script (unless the name of the script starts with a slash). Typically this is used to emulate `#!' startup on machines that don't support `#!', in the following manner: #!/usr/bin/perl eval "exec /usr/bin/perl -S $0 $*" if $running_under_some_shell; The system ignores the first line and feeds the script to `/bin/sh', which proceeds to try to execute the *perl* script as a shell script. The shell executes the second line as a normal shell command, and thus starts up the *perl* interpreter. On some systems `$0' doesn't always contain the full pathname, so the `-S' tells *perl* to search for the script if necessary. After *perl* locates the script, it parses the lines and ignores them because the variable `$running_under_some_shell' is never true. A better construct than `$*' would be `${1+"$@"}', which handles embedded spaces and such in the filenames, but doesn't work if the script is being interpreted by `csh'. In order to start up `sh' rather than `csh', some systems may have to replace the `#!' line with a line containing just a colon, which will be politely ignored by *perl*. Other systems can't control that, and need a totally devious construct that will work under any of `csh', `sh' or `perl', such as the following: eval '(exit $?0)' && eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' & eval 'exec /usr/bin/perl -S $0 $argv:q' if 0; `-u' causes *perl* to dump core after compiling your script. You can then take this core dump and turn it into an executable file by using the `undump' program (not supplied). This speeds startup at the expense of some disk space (which you can minimize by stripping the executable). (Still, a "hello world" executable comes out to about 200K on my machine.) If you are going to run your executable as a set-id program then you should probably compile it using taintperl rather than normal perl. If you want to execute a portion of your script before dumping, use the `dump' operator instead. Note: availability of `undump' is platform specific and may not be available for a specific port of *perl*. `-U' allows *perl* to do unsafe operations. Currently the only `unsafe' operations are the unlinking of directories while running as superuser, and running setuid programs with fatal taint checks turned into warnings. `-v' prints the version and patchlevel of your *perl* executable. `-w' prints warnings about identifiers that are mentioned only once, and scalar variables that are used before being set. Also warns about redefined subroutines, and references to undefined filehandles or filehandles opened readonly that you are attempting to write on. Also warns you if you use `==' on values that don't look like numbers, and if your subroutines recurse more than 100 deep. `-x directory' tells *perl* that the script is embedded in a message. Leading garbage will be discarded until the first line that starts with `#!' and contains the string "perl". Any meaningful switches on that line will be applied (but only one group of switches, as with normal `#!' processing). If a directory name is specified, *perl* will switch to that directory before running the script. The `-x' switch only controls the the disposal of leading garbage. The script must be terminated with `__END__' if there is trailing garbage to be ignored (the script can process any or all of the trailing garbage via the `DATA' filehandle if desired). File: perl.info, Node: Data Types, Next: Syntax, Prev: Perl Startup, Up: Top Data Types and Objects ********************** *Perl* has three data types: scalars, arrays of scalars, and associative arrays of scalars. Normal arrays are indexed by number, and associative arrays by string. The interpretation of operations and values in perl sometimes depends on the requirements of the context around the operation or value. There are three major contexts: "string", "numeric" and "array". Certain operations return array values in contexts wanting an array, and scalar values otherwise. (If this is true of an operation it will be mentioned in the documentation for that operation.) Operations which return scalars don't care whether the context is looking for a string or a number, but scalar variables and values are interpreted as strings or numbers as appropriate to the context. A scalar is interpreted as TRUE in the boolean sense if it is not the null string or 0. Booleans returned by operators are 1 for TRUE and 0 or '' (the null string [two single right quotes]) for FALSE. There are actually two varieties of null strings: "defined" and "undefined". Undefined null strings are returned when there is no real value for something, such as when there was an error, or at end of file, or when you refer to an uninitialized variable or element of an array. An undefined null string may become defined the first time you access it, but prior to that you can use the `defined()' operator to determine whether the value is defined or not. References to scalar variables always begin with `$', even when referring to a scalar that is part of an array. Thus: $days # a simple scalar variable $days[28] # 29th element of array @days $days{'Feb'} # one value from an associative array $#days # last index of array @days but entire arrays or array slices are denoted by `@': @days # ($days[0], $days[1],... $days[n]) @days[3,4,5] # same as @days[3..5] @days{'a','c'} # same as ($days{'a'},$days{'c'}) and entire associative arrays are denoted by `%': %days # (key1, val1, key2, val2 ...) Any of these eight constructs may serve as an lvalue, that is, may be assigned to. (It also turns out that an assignment is itself an lvalue in certain contexts--see examples under `s', `tr' and `chop'.) Assignment to a scalar evaluates the righthand side in a scalar context, while assignment to an array or array slice evaluates the righthand side in an array context. You may find the length of array `@days' by evaluating `$#days', as in `csh'. (Actually, it's not the length of the array, it's the subscript of the last element, since there is (ordinarily) a 0th element.) Assigning to `$#days' changes the length of the array. Shortening an array by this method does not actually destroy any values. Lengthening an array that was previously shortened recovers the values that were in those elements. You can also gain some measure of efficiency by preextending an array that is going to get big. (You can also extend an array by assigning to an element that is off the end of the array. This differs from assigning to `$#whatever' in that intervening values are set to null rather than recovered.) You can truncate an array down to nothing by assigning the null list `()' to it. The following are exactly equivalent: @whatever = (); $#whatever = $[ - 1; If you evaluate an array in a scalar context, it returns the length of the array. The following is always true: scalar(@whatever) == $#whatever - $[ + 1; If you evaluate an associative array in a scalar context, it returns a value which is true if and only if the array contains any elements. (If there are any elements, the value returned is a string consisting of the number of used buckets and the number of allocated buckets, separated by a slash.) Multi-dimensional arrays are not directly supported, but see the discussion of the `$;' variable later for a means of emulating multiple subscripts with an associative array. You could also write a subroutine to turn multiple subscripts into a single subscript. Every data type has its own namespace. You can, without fear of conflict, use the same name for a scalar variable, an array, an associative array, a filehandle, a subroutine name, and/or a label. Since variable and array references always start with `$', `@', or `%', the "reserved" words aren't in fact reserved with respect to variable names. (They *ARE* reserved with respect to labels and filehandles, however, which don't have an initial special character. Hint: you could say `open(LOG,'logfile')' rather than `open(log,'logfile')'. Using uppercase filehandles also improves readability and protects you from conflict with future reserved words.) Case *IS* significant---`FOO', `Foo' and `foo' are all different names. Names which start with a letter may also contain digits and underscores. Names which do not start with a letter are limited to one character, e.g. `$%' or `$$'. (Most of the one character names have a predefined significance to *perl*. More later.) Numeric literals are specified in any of the usual floating point or integer formats: 12345 12345.67 .23E-10 0xffff # hex 0377 # octal 4_294_967_296 String literals are delimited by either single or double quotes. They work much like shell quotes: double-quoted string literals are subject to backslash and variable substitution; single-quoted strings are not (except for \' and \\). The usual backslash rules apply for making characters such as newline, tab, etc., as well as some more exotic forms: \t tab \n newline \r return \f form feed \b backspace \a alarm (bell) \e escape \033 octal char \x1b hex char \c[ control char \l lowercase next char \u uppercase next char \L lowercase till \E \U uppercase till \E \E end case modification You can also embed newlines directly in your strings, i.e. they can end on a different line than they begin. This is nice, but if you forget your trailing quote, the error will not be reported until *perl* finds another line containing the quote character, which may be much further on in the script. Variable substitution inside strings is limited to scalar variables, normal array values, and array slices. (In other words, identifiers beginning with `$' or `@', followed by an optional bracketed expression as a subscript.) The following code segment prints out `The price is $100.' $Price = '$100'; # not interpreted print "The price is $Price.\n"; # interpreted Note that you can put curly brackets around the identifier to delimit it from following alphanumerics. Also note that a single quoted string must be separated from a preceding word by a space, since single quote is a valid character in an identifier. *Note Packages::, for more info. Two special literals are `__LINE__' and `__FILE__', which represent the current line number and filename at that point in your program. They may only be used as separate tokens; they will not be interpolated into strings. In addition, the token `__END__' may be used to indicate the logical end of the script before the actual end of file. Any following text is ignored, but may be read via the `DATA' filehandle. (The `DATA' filehandle may read data only from the main script, but not from any required file or evaluated string.) The two control characters `' and `' are synonyms for `__END__'. A word that doesn't have any other interpretation in the grammar will be treated as if it had single quotes around it. For this purpose, a word consists only of alphanumeric characters and underline, and must start with an alphabetic character. As with filehandles and labels, a bare word that consists entirely of lowercase letters risks conflict with future reserved words, and if you use the `-w' switch, *perl* will warn you about any such words. Array values are interpolated into double-quoted strings by joining all the elements of the array with the delimiter specified in the `$"' variable, space by default. (Since in versions of perl prior to 3.0 the `@' character was not a metacharacter in double-quoted strings, the interpolation of `@array', `$array[EXPR]', `@array[LIST]', `$array{EXPR}', or `@array{LIST}' only happens if array is referenced elsewhere in the program or is predefined.) The following are equivalent: $temp = join($",@ARGV); system "echo $temp"; system "echo @ARGV"; Within search patterns (which also undergo double-quotish substitution) there is a bad ambiguity: Is `/$foo[bar]/' to be interpreted as `/${foo}[bar]/' (where `[bar]' is a character class for the regular expression) or as `/${foo[bar]}/' (where `[bar]' is the subscript to array `@foo')? If `@foo' doesn't otherwise exist, then it's obviously a character class. If `@foo' exists, perl takes a good guess about `[bar]', and is almost always right. If it does guess wrong, or if you're just plain paranoid, you can force the correct interpretation with curly brackets as above. A line-oriented form of quoting is based on the shell here-is syntax. Following a `<<' you specify a string to terminate the quoted material, and all lines following the current line down to the terminating string are the value of the item. The terminating string may be either an identifier (a word), or some quoted text. If quoted, the type of quotes you use determines the treatment of the text, just as in regular quoting. An unquoted identifier works like double quotes. There must be no space between the `<<' and the identifier. (If you put a space it will be treated as a null identifier, which is valid, and matches the first blank line--see Merry Christmas example below.) The terminating string must appear by itself (unquoted and with no surrounding whitespace) on the terminating line. print <) { print; } while () { print; } for (;;) { print; } print while $_ = ; print while ; The filehandles `STDIN', `STDOUT' and `STDERR' are predefined. (The filehandles `stdin', `stdout' and `stderr' will also work except in packages, where they would be interpreted as local identifiers rather than global.) Additional filehandles may be created with the `open' function. If a `' is used in a context that is looking for an array, an array consisting of all the input lines is returned, one line per array element. It's easy to make a LARGE data space this way, so use with care. The null filehandle `<>' is special and can be used to emulate the behavior of `sed' and `awk'. Input from `<>' comes either from standard input, or from each file listed on the command line. Here's how it works: the first time `<>' is evaluated, the `ARGV' array is checked, and if it is null, `$ARGV[0]' is set to `-', which when opened gives you standard input. The `ARGV' array is then processed as a list of filenames. The loop while (<>) { ... # code for each line } is equivalent to the following Perl-like pseudo code: unshift(@ARGV, '-') if $#ARGV < $[; while ($ARGV = shift) { open(ARGV, $ARGV); while () { ... # code for each line } } except that it isn't as cumbersome to say, and will actually work. It really does shift array `ARGV' and put the current filename into variable `ARGV'. It also uses filehandle `ARGV' internally---`<>' is just a synonym for `', which is magical. (The pseudo code above doesn't work because it treats `' as non-magical.) You can modify `@ARGV' before the first `<>' as long as the array ends up containing the list of filenames you really want. Line numbers (`$.') continue as if the input was one big happy file. (But see example under `eof' for how to reset line numbers on each file.) If you want to set `@ARGV' to your own list of files, go right ahead. If you want to pass switches into your script, you can put a loop on the front like this: while ($_ = $ARGV[0], /^-/) { shift; last if /^--$/; /^-D(.*)/ && ($debug = $1); /^-v/ && $verbose++; ... # other switches } while (<>) { ... # code for each line } The `<>' symbol will return FALSE only once. If you call it again after this it will assume you are processing another `@ARGV' list, and if you haven't set `@ARGV', will input from `STDIN'. If the string inside the angle brackets is a reference to a scalar variable (e.g. `<$foo>'), then that variable contains the name of the filehandle to input from. If the string inside angle brackets is not a filehandle, it is interpreted as a filename pattern to be globbed, and either an array of filenames or the next filename in the list is returned, depending on context. One level of `$' interpretation is done first, but you can't say `<$foo>' because that's an indirect filehandle as explained in the previous paragraph. You could insert curly brackets to force interpretation as a filename glob: `<${foo}>'. Example: while (<*.c>) { chmod 0644, $_; } is equivalent to open(foo, "echo *.c | tr -s ' \t\r\f' '\\012\\012\\012\\012'|"); while () { chop; chmod 0644, $_; } In fact, it's currently implemented that way. (Which means it will not work on filenames with spaces in them unless you have `/bin/csh' on your machine.) Of course, the shortest way to do the above is: chmod 0644, <*.c>; ======== Info file: perl.info, -*-Text-*- produced by `texinfo-format-buffer' from file `perl.texinfo' using `texinfmt.el' version 2.30 of 18 May 1993. This file documents perl, Practical Extraction and Report Language, and was originally based on Larry Wall's unix-style man page for perl. GNU Texinfo version adapted by Jeff Kellem . Copyright (C) 1989, 1990, 1991, 1992, 1993 Larry Wall Texinfo version Copyright (C) 1990, 1991, 1993 Jeff Kellem Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled "GNU General Public License" and "Conditions for Using Perl" are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the section entitled "GNU General Public License" and this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. File: perl.info, Node: Top, Next: Introduction, Prev: (dir), Up: (dir) This Info file contains edition 0.6, dated 13 September 1993, "printed" on 13 Sep 1993 of the Perl Manual for Perl version 4.0 patchlevel 36. This is a *DRAFT* copy of the Texinfo version of the perl manual! * Menu: * Introduction:: A quick introduction to the manual. * Copying:: The GNU General Public License says how you can copy and share Perl. * Conditions:: Conditions for Using Perl. (Larry Wall's interpretation of the GPL and how it affects perl scripts.) * Preface:: A quick description of perl. (The hype.) * Perl Startup:: Where perl looks for scripts; perl's options. * Data Types:: Perl's data types and objects. * Syntax:: Perl language syntax. * Compound Statements:: What is a compound statement in Perl? * Simple Statements:: What is a simple statement in Perl? * Expressions:: What are valid expressions in Perl? * Commands:: All of perl's functions. * Precedence:: Operator precedence in Perl. * Subroutines:: Defining subroutines in Perl. * Passing By Reference:: How to pass args by reference in Perl. * Regular Expressions:: Perl's pattern matching capabilities. * Formats:: Report formats. * Interprocess Communication:: Networking in Perl. * Predefined Names:: Predefined variables. * Packages:: What is a Perl package? Find out here. * Style:: Suggestions on programming style. * Debugging:: The Perl debugger. * Setuid Scripts:: Setuid Perl scripts. * Environment:: Environment variables Perl utilizes. * a2p:: Awk to Perl conversion program. * s2p:: Sed to Perl conversion program. * h2ph:: Converting C header files into Perl header files. * Diagnostics:: What do the error messages mean? * Traps:: Traps and Pitfalls for C, sh, sed, awk programmers. * Bugs:: Known problems in Perl. (Mainly dependent upon your machine.) * Credits:: The Credits. Who worked on what. * Errata:: Errata and Addenda. * Command Summary:: Summary of commands (syntax only). Indices * Concept Index:: (mega ;-)Index of Concepts. * Function Index:: Index of Commands/Functions. File: perl.info, Node: Introduction, Next: Copying, Prev: Top, Up: Top Introduction ************ This Texinfo manual describes PERL, the Practical Extraction and Report Language. The manual is, currently, mainly a conversion of Larry Wall's original unix-style man page into Texinfo format. In the future, new sections will be added, such as tutorial sections and more examples. The Texinfo version of the perl manual is maintained and distributed by Jeff Kellem. His electronic mail address is composer@Beyond.Dreams.ORG. There is a mailing list for discussion of the Texinfo version of the perl manual and a mailing address for reporting bugs in this version of the manual. They are: *Mailing Address* *What The Address Is For* perl-manual-request@Beyond.Dreams.ORG administrivia (add/drop requests) perl-manual@Beyond.Dreams.ORG discussion of the Texinfo perl manual bug-perl-manual@Beyond.Dreams.ORG reporting bugs in the perl manual If you would like to join the discussion of the perl manual, send a note to perl-manual-request@Beyond.Dreams.ORG The latest edition of the Texinfo version of the Perl manual is available via anonymous ftp from: ftp.dreams.org in the /pub/perl-manual directory. File: perl.info, Node: Copying, Next: Conditions, Prev: Introduction, Up: Top GNU General Public License ************************** Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ======== The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 1. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 2. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 3. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: * cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and * cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). * If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. * You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 4. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: * accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, * accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, * accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 5. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 6. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 7. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 8. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 9. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 10. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 11. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms ================================== If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. Copyright (C) 19YY NAME OF AUTHOR This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. SIGNATURE OF TY COON, 1 April 1989 Ty Coon, President of Vice That's all there is to it! File: perl.info, Node: Conditions, Next: Preface, Prev: Copying, Up: Top Conditions for Using Perl ************************* [ Note: The following is from the author of Perl, Larry Wall. ] My interpretation of the GNU General Public License is that no Perl script falls under the terms of the License unless you explicitly put said script under the terms of the License yourself. Furthermore, any object code linked with uperl.o does not automatically fall under the terms of the License, provided such object code only adds definitions of subroutines and variables, and does not otherwise impair the resulting interpreter from executing any standard Perl script. I consider linking in C subroutines in this manner to be the moral equivalent of defining subroutines in the Perl language itself. You may sell such an object file as proprietary provided that you provide or offer to provide the Perl source, as specified by the GNU General Public License. (This is merely an alternate way of specifying input to the program.) You may also sell a binary produced by the dumping of a running Perl script that belongs to you, provided that you provide or offer to provide the Perl source as specified by the License. (The fact that a Perl interpreter and your code are in the same binary file is, in this case, a form of mere aggregation.) This is my interpretation of the License. If you still have concerns or difficulties understanding my intent, feel free to contact me. File: perl.info, Node: Preface, Next: Perl Startup, Prev: Conditions, Up: Top