home *** CD-ROM | disk | FTP | other *** search
/ Tutto per Internet / Internet.iso / soft95 / Html / PerlW32 / perl.pod < prev    next >
Encoding:
Text File  |  1996-01-31  |  10.7 KB  |  297 lines

  1. =head1 NAME
  2.  
  3. perl for Win32 - Practical Extraction and Report Language for the Win32 platform.
  4.  
  5. =head1 SYNOPSIS
  6.  
  7. For ease of access, the Perl manual has been split up into a number
  8. of sections:
  9.  
  10.     perl    Perl overview (this section)
  11.     perldata    Perl data structures
  12.     perlsyn    Perl syntax
  13.     perlop    Perl operators and precedence
  14.     perlre    Perl regular expressions
  15.     perlrun    Perl execution and options
  16.     perlfunc    Perl builtin functions
  17.     perlvar    Perl predefined variables
  18.     perlsub    Perl subroutines
  19.     perlmod    Perl modules
  20.     perlref    Perl references and nested data structures
  21.     perlobj    Perl objects
  22.     perlbot    Perl OO tricks and examples
  23.     perldebug    Perl debugging
  24.     perldiag    Perl diagnostic messages
  25.     perlform    Perl formats
  26.     perlipc    Perl interprocess communication
  27.     perlsec    Perl security
  28.     perltrap    Perl traps for the unwary
  29.     perlstyle    Perl style guide
  30.     perlapi    Perl application programming interface
  31.     perlguts    Perl internal functions for those doing extensions 
  32.     perlcall    Perl calling conventions from C
  33.     perlovl    Perl overloading semantics
  34.     perlembed    Perl how to embed perl in your C or C++ app
  35.     perlpod    Perl plain old documentation
  36.     perlbook    Perl book information
  37.  
  38. B<Win32 Specific>
  39.  
  40.     win32    Perl for Win32 Overview
  41.     win32ext    Perl for Win32 miscellaneous extensions
  42.     oleauto    Perl OLE Automation
  43.  
  44. (If you're intending to read these straight through for the first time,
  45. the suggested order will tend to reduce the number of forward references.)
  46.  
  47. Additional documentation for perl modules is available in
  48. the F</usr/local/lib/perl5/man/man3> directory.  You can view this
  49. with a man(1) program by including the following in the
  50. appropriate start-up files.  (You may have to adjust the path to
  51. match $Config{'man3dir'}.)
  52.  
  53.     .profile (for sh, bash or ksh users):
  54.     MANPATH=$MANPATH:/usr/local/lib/perl5/man
  55.     export MANPATH
  56.  
  57.     .login (for csh or tcsh users):
  58.     setenv MANPATH $MANPATH:/usr/local/lib/perl5/man
  59.  
  60. If that doesn't work for some reason, you can still use the
  61. supplied perldoc script to view module information.
  62.  
  63. If something strange has gone wrong with your program and you're not
  64. sure where you should look for help, try the B<-w> switch first.  It
  65. will often point out exactly where the trouble is.
  66.  
  67. =head1 DESCRIPTION
  68.  
  69. Perl is an interpreted language optimized for scanning arbitrary
  70. text files, extracting information from those text files, and printing
  71. reports based on that information.  It's also a good language for many
  72. system management tasks.  The language is intended to be practical
  73. (easy to use, efficient, complete) rather than beautiful (tiny,
  74. elegant, minimal).  It combines (in the author's opinion, anyway) some
  75. of the best features of C, B<sed>, B<awk>, and B<sh>, so people
  76. familiar with those languages should have little difficulty with it.
  77. (Language historians will also note some vestiges of B<csh>, Pascal,
  78. and even BASIC-PLUS.)  Expression syntax corresponds quite closely to C
  79. expression syntax.  Unlike most Unix utilities, Perl does not
  80. arbitrarily limit the size of your data--if you've got the memory,
  81. Perl can slurp in your whole file as a single string.  Recursion is
  82. of unlimited depth.  And the hash tables used by associative arrays
  83. grow as necessary to prevent degraded performance.  Perl uses
  84. sophisticated pattern matching techniques to scan large amounts of data
  85. very quickly.  Although optimized for scanning text, Perl can also
  86. deal with binary data, and can make dbm files look like associative
  87. arrays (where dbm is available).  Setuid Perl scripts are safer than
  88. C programs through a dataflow tracing mechanism which prevents many
  89. stupid security holes.  If you have a problem that would ordinarily use
  90. B<sed> or B<awk> or B<sh>, but it exceeds their capabilities or must
  91. run a little faster, and you don't want to write the silly thing in C,
  92. then Perl may be for you.  There are also translators to turn your
  93. B<sed> and B<awk> scripts into Perl scripts.
  94.  
  95. But wait, there's more...
  96.  
  97. Perl version 5 is nearly a complete rewrite, and provides
  98. the following additional benefits:
  99.  
  100. =over 5
  101.  
  102. =item * Many usability enhancements
  103.  
  104. It is now possible to write much more readable Perl code (even within
  105. regular expressions).  Formerly cryptic variable names can be replaced
  106. by mnemonic identifiers.  Error messages are more informative, and the
  107. optional warnings will catch many of the mistakes a novice might make.
  108. This cannot be stressed enough.  Whenever you get mysterious behavior,
  109. try the B<-w> switch!!!  Whenever you don't get mysterious behavior,
  110. try using B<-w> anyway.
  111.  
  112. =item * Simplified grammar
  113.  
  114. The new yacc grammar is one half the size of the old one.  Many of the
  115. arbitrary grammar rules have been regularized.  The number of reserved
  116. words has been cut by 2/3.  Despite this, nearly all old Perl scripts
  117. will continue to work unchanged.
  118.  
  119. =item * Lexical scoping
  120.  
  121. Perl variables may now be declared within a lexical scope, like "auto"
  122. variables in C.  Not only is this more efficient, but it contributes
  123. to better privacy for "programming in the large".
  124.  
  125. =item * Arbitrarily nested data structures
  126.  
  127. Any scalar value, including any array element, may now contain a
  128. reference to any other variable or subroutine.  You can easily create
  129. anonymous variables and subroutines.  Perl manages your reference
  130. counts for you.
  131.  
  132. =item * Modularity and reusability
  133.  
  134. The Perl library is now defined in terms of modules which can be easily
  135. shared among various packages.  A package may choose to import all or a
  136. portion of a module's published interface.  Pragmas (that is, compiler
  137. directives) are defined and used by the same mechanism.
  138.  
  139. =item * Object-oriented programming
  140.  
  141. A package can function as a class.  Dynamic multiple inheritance and
  142. virtual methods are supported in a straightforward manner and with very
  143. little new syntax.  Filehandles may now be treated as objects.
  144.  
  145. =item * Embeddible and Extensible
  146.  
  147. Perl may now be embedded easily in your C or C++ application, and can
  148. either call or be called by your routines through a documented
  149. interface.  The XS preprocessor is provided to make it easy to glue
  150. your C or C++ routines into Perl.  Dynamic loading of modules is
  151. supported.
  152.  
  153. =item * POSIX compliant
  154.  
  155. A major new module is the POSIX module, which provides access to all
  156. available POSIX routines and definitions, via object classes where
  157. appropriate.
  158.  
  159. =item * Package constructors and destructors
  160.  
  161. The new BEGIN and END blocks provide means to capture control as
  162. a package is being compiled, and after the program exits.  As a
  163. degenerate case they work just like awk's BEGIN and END when you
  164. use the B<-p> or B<-n> switches.
  165.  
  166. =item * Multiple simultaneous DBM implementations
  167.  
  168. A Perl program may now access DBM, NDBM, SDBM, GDBM, and Berkeley DB
  169. files from the same script simultaneously.  In fact, the old dbmopen
  170. interface has been generalized to allow any variable to be tied
  171. to an object class which defines its access methods.
  172.  
  173. =item * Subroutine definitions may now be autoloaded
  174.  
  175. In fact, the AUTOLOAD mechanism also allows you to define any arbitrary
  176. semantics for undefined subroutine calls.  It's not just for autoloading.
  177.  
  178. =item * Regular expression enhancements
  179.  
  180. You can now specify non-greedy quantifiers.  You can now do grouping
  181. without creating a backreference.  You can now write regular expressions
  182. with embedded whitespace and comments for readability.  A consistent
  183. extensibility mechanism has been added that is upwardly compatible with
  184. all old regular expressions.
  185.  
  186. =back
  187.  
  188. Ok, that's I<definitely> enough hype.
  189.  
  190. =head1 ENVIRONMENT
  191.  
  192. =over 12
  193.  
  194. =item HOME
  195.  
  196. Used if chdir has no argument.
  197.  
  198. =item LOGDIR
  199.  
  200. Used if chdir has no argument and HOME is not set.
  201.  
  202. =item PATH
  203.  
  204. Used in executing subprocesses, and in finding the script if B<-S> is
  205. used.
  206.  
  207. =item PERL5LIB
  208.  
  209. A colon-separated list of directories in which to look for Perl library
  210. files before looking in the standard library and the current
  211. directory.  If PERL5LIB is not defined, PERLLIB is used.
  212.  
  213. =item PERL5DB
  214.  
  215. The command used to get the debugger code.  If unset, uses
  216.  
  217.     BEGIN { require 'perl5db.pl' }
  218.  
  219. =item PERLLIB
  220.  
  221. A colon-separated list of directories in which to look for Perl library
  222. files before looking in the standard library and the current
  223. directory.  If PERL5LIB is defined, PERLLIB is not used.
  224.  
  225.  
  226. =back
  227.  
  228. Apart from these, Perl uses no other environment variables, except
  229. to make them available to the script being executed, and to child
  230. processes.  However, scripts running setuid would do well to execute
  231. the following lines before doing anything else, just to keep people
  232. honest:
  233.  
  234.     $ENV{'PATH'} = '/bin:/usr/bin';    # or whatever you need
  235.     $ENV{'SHELL'} = '/bin/sh' if defined $ENV{'SHELL'};
  236.     $ENV{'IFS'} = ''          if defined $ENV{'IFS'};
  237.  
  238. =head1 AUTHOR
  239.  
  240. Larry Wall <F<lwall@netlabs.com.>, with the help of oodles of other folks.
  241.  
  242. =head1 FILES
  243.  
  244.  "/tmp/perl-e$$"    temporary file for -e commands
  245.  "@INC"            locations of perl 5 libraries
  246.  
  247. =head1 SEE ALSO
  248.  
  249.  a2p    awk to perl translator
  250.  s2p    sed to perl translator
  251.  
  252. =head1 DIAGNOSTICS
  253.  
  254. The B<-w> switch produces some lovely diagnostics.
  255.  
  256. See L<perldiag> for explanations of all Perl's diagnostics.
  257.  
  258. Compilation errors will tell you the line number of the error, with an
  259. indication of the next token or token type that was to be examined.
  260. (In the case of a script passed to Perl via B<-e> switches, each
  261. B<-e> is counted as one line.)
  262.  
  263. Setuid scripts have additional constraints that can produce error
  264. messages such as "Insecure dependency".  See L<perlsec>.
  265.  
  266. Did we mention that you should definitely consider using the B<-w>
  267. switch?
  268.  
  269. =head1 BUGS
  270.  
  271. The B<-w> switch is not mandatory.
  272.  
  273. Perl is at the mercy of your machine's definitions of various
  274. operations such as type casting, atof() and sprintf().
  275.  
  276. If your stdio requires a seek or eof between reads and writes on a
  277. particular stream, so does Perl.  (This doesn't apply to sysread()
  278. and syswrite().)
  279.  
  280. While none of the built-in data types have any arbitrary size limits
  281. (apart from memory size), there are still a few arbitrary limits:  a
  282. given identifier may not be longer than 255 characters, and no
  283. component of your PATH may be longer than 255 if you use B<-S>.  A regular
  284. expression may not compile to more than 32767 bytes internally.
  285.  
  286. Perl actually stands for Pathologically Eclectic Rubbish Lister, but
  287. don't tell anyone I said that.
  288.  
  289. =head1 NOTES
  290.  
  291. The Perl motto is "There's more than one way to do it."  Divining
  292. how many more is left as an exercise to the reader.
  293.  
  294. The three principle virtues of a programmer are Laziness,
  295. Impatience, and Hubris.  See the Camel Book for why.
  296.  
  297.