home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / u_man / cat1 / perl.z / perl
Encoding:
Text File  |  2002-10-03  |  17.5 KB  |  463 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      perl - Practical Extraction and Report Language
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ppppeeeerrrrllll [ ----ssssTTTTuuuuUUUU ]      [ ----hhhhvvvv ] [ ----VVVV[:_c_o_n_f_i_g_v_a_r] ]
  13.           [ ----ccccwwww ] [ ----dddd[:_d_e_b_u_g_g_e_r] ] [ ----DDDD[_n_u_m_b_e_r/_l_i_s_t] ]
  14.           [ ----ppppnnnnaaaa ] [ ----FFFF_p_a_t_t_e_r_n ] [ ----llll[_o_c_t_a_l] ] [ ----0000[_o_c_t_a_l] ]
  15.           [ ----IIII_d_i_r ] [ ----mmmm[----]_m_o_d_u_l_e ] [ ----MMMM[----]'_m_o_d_u_l_e...' ]      [ ----PPPP ]
  16.           [ ----SSSS ]      [ ----xxxx[_d_i_r] ]      [ ----iiii[_e_x_t_e_n_s_i_o_n] ]
  17.           [ ----eeee '_c_o_m_m_a_n_d' ] [ -------- ] [ _p_r_o_g_r_a_m_f_i_l_e ] [ _a_r_g_u_m_e_n_t ]...
  18.  
  19.      For ease of access, the Perl manual has been split up into a number of
  20.      sections:
  21.  
  22.          perl                Perl overview (this section)
  23.          perldelta           Perl changes since previous version
  24.          perlfaq             Perl frequently asked questions
  25.          perltoc             Perl documentation table of contents
  26.  
  27.          perldata            Perl data structures
  28.          perlsyn             Perl syntax
  29.          perlop              Perl operators and precedence
  30.          perlre              Perl regular expressions
  31.          perlrun             Perl execution and options
  32.          perlfunc            Perl builtin functions
  33.          perlvar             Perl predefined variables
  34.          perlsub             Perl subroutines
  35.          perlmod             Perl modules: how they work
  36.          perlmodlib          Perl modules: how to write and use
  37.          perlmodinstall      Perl modules: how to install from CPAN
  38.          perlform            Perl formats
  39.          perllocale          Perl locale support
  40.  
  41.          perlref             Perl references
  42.          perldsc             Perl data structures intro
  43.          perllol             Perl data structures: lists of lists
  44.          perltoot            Perl OO tutorial
  45.          perlobj             Perl objects
  46.          perltie             Perl objects hidden behind simple variables
  47.          perlbot             Perl OO tricks and examples
  48.          perlipc             Perl interprocess communication
  49.  
  50.          perldebug           Perl debugging
  51.          perldiag            Perl diagnostic messages
  52.          perlsec             Perl security
  53.          perltrap            Perl traps for the unwary
  54.          perlport            Perl portability guide
  55.          perlstyle           Perl style guide
  56.  
  57.          perlpod             Perl plain old documentation
  58.          perlbook            Perl book information
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  71.  
  72.  
  73.  
  74.          perlembed           Perl ways to embed perl in your C or C++ application
  75.          perlapio            Perl internal IO abstraction interface
  76.          perlxs              Perl XS application programming interface
  77.          perlxstut           Perl XS tutorial
  78.          perlguts            Perl internal functions for those doing extensions
  79.          perlcall            Perl calling conventions from C
  80.  
  81.          perlhist            Perl history records
  82.  
  83.      (If you're intending to read these straight through for the first time,
  84.      the suggested order will tend to reduce the number of forward
  85.      references.)
  86.  
  87.      The above manpages are installed in the /_u_s_r/_s_h_a_r_e/_c_a_t_m_a_n/_u__m_a_n/_c_a_t_1/
  88.      directory.
  89.  
  90.      Extensive additional documentation for Perl modules is available.  The
  91.      IRIX configuration of perl places the documentation for the standard
  92.      modules in the /_u_s_r/_s_h_a_r_e/_c_a_t_m_a_n/_p__m_a_n/_c_a_t_3/_p_e_r_l_5/ directory.  The
  93.      documentation for third-party modules will by default be installed into
  94.      the /_u_s_r/_c_a_t_m_a_n/_l_o_c_a_l/_m_a_n_3/_p_e_r_l_5/ directory.  These directories are all
  95.      in the standard IRIX MANPATH.
  96.  
  97.      If something strange has gone wrong with your program and you're not sure
  98.      where you should look for help, try the ----wwww switch first.  It will often
  99.      point out exactly where the trouble is.
  100.  
  101. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  102.      Perl is a language optimized for scanning arbitrary text files,
  103.      extracting information from those text files, and printing reports based
  104.      on that information.  It's also a good language for many system
  105.      management tasks.  The language is intended to be practical (easy to use,
  106.      efficient, complete) rather than beautiful (tiny, elegant, minimal).
  107.  
  108.      Perl combines (in the author's opinion, anyway) some of the best features
  109.      of C, sssseeeedddd, aaaawwwwkkkk, and sssshhhh, so people familiar with those languages should
  110.      have little difficulty with it.  (Language historians will also note some
  111.      vestiges of ccccsssshhhh, Pascal, and even BASIC-PLUS.)  Expression syntax
  112.      corresponds quite closely to C expression syntax.  Unlike most Unix
  113.      utilities, Perl does not arbitrarily limit the size of your data--if
  114.      you've got the memory, Perl can slurp in your whole file as a single
  115.      string.  Recursion is of unlimited depth.  And the tables used by hashes
  116.      (previously called "associative arrays") grow as necessary to prevent
  117.      degraded performance.  Perl uses sophisticated pattern matching
  118.      techniques to scan large amounts of data very quickly.  Although
  119.      optimized for scanning text, Perl can also deal with binary data, and can
  120.      make dbm files look like hashes.  Setuid Perl scripts are safer than C
  121.      programs through a dataflow tracing mechanism which prevents many stupid
  122.      security holes.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  137.  
  138.  
  139.  
  140.      If you have a problem that would ordinarily use sssseeeedddd or aaaawwwwkkkk or sssshhhh, but it
  141.      exceeds their capabilities or must run a little faster, and you don't
  142.      want to write the silly thing in C, then Perl may be for you.  There are
  143.      also translators to turn your sssseeeedddd and aaaawwwwkkkk scripts into Perl scripts.
  144.  
  145.      But wait, there's more...
  146.  
  147.      Perl version 5 is nearly a complete rewrite, and provides the following
  148.      additional benefits:
  149.  
  150.      +o Many usability enhancements
  151.           It is now possible to write much more readable Perl code (even
  152.           within regular expressions).  Formerly cryptic variable names can be
  153.           replaced by mnemonic identifiers.  Error messages are more
  154.           informative, and the optional warnings will catch many of the
  155.           mistakes a novice might make.  This cannot be stressed enough.
  156.           Whenever you get mysterious behavior, try the ----wwww switch!!!  Whenever
  157.           you don't get mysterious behavior, try using ----wwww anyway.
  158.  
  159.      +o Simplified grammar
  160.           The new yacc grammar is one half the size of the old one.  Many of
  161.           the arbitrary grammar rules have been regularized.  The number of
  162.           reserved words has been cut by 2/3.  Despite this, nearly all old
  163.           Perl scripts will continue to work unchanged.
  164.  
  165.      +o Lexical scoping
  166.           Perl variables may now be declared within a lexical scope, like
  167.           "auto" variables in C.  Not only is this more efficient, but it
  168.           contributes to better privacy for "programming in the large".
  169.           Anonymous subroutines exhibit deep binding of lexical variables
  170.           (closures).
  171.  
  172.      +o Arbitrarily nested data structures
  173.           Any scalar value, including any array element, may now contain a
  174.           reference to any other variable or subroutine.  You can easily
  175.           create anonymous variables and subroutines.  Perl manages your
  176.           reference counts for you.
  177.  
  178.      +o Modularity and reusability
  179.           The Perl library is now defined in terms of modules which can be
  180.           easily shared among various packages.  A package may choose to
  181.           import all or a portion of a module's published interface.  Pragmas
  182.           (that is, compiler directives) are defined and used by the same
  183.           mechanism.
  184.  
  185.      +o Object-oriented programming
  186.           A package can function as a class.  Dynamic multiple inheritance and
  187.           virtual methods are supported in a straightforward manner and with
  188.           very little new syntax.  Filehandles may now be treated as objects.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  203.  
  204.  
  205.  
  206.      +o Embeddable and Extensible
  207.           Perl may now be embedded easily in your C or C++ application, and
  208.           can either call or be called by your routines through a documented
  209.           interface.  The XS preprocessor is provided to make it easy to glue
  210.           your C or C++ routines into Perl.  Dynamic loading of modules is
  211.           supported, and Perl itself can be made into a dynamic library.
  212.  
  213.      +o POSIX compliant
  214.           A major new module is the POSIX module, which provides access to all
  215.           available POSIX routines and definitions, via object classes where
  216.           appropriate.
  217.  
  218.      +o Package constructors and destructors
  219.           The new BEGIN and END blocks provide means to capture control as a
  220.           package is being compiled, and after the program exits.  As a
  221.           degenerate case they work just like awk's BEGIN and END when you use
  222.           the ----pppp or ----nnnn switches.
  223.  
  224.      +o Multiple simultaneous DBM implementations
  225.           A Perl program may now access DBM, NDBM, SDBM, GDBM, and Berkeley DB
  226.           files from the same script simultaneously.  In fact, the old dbmopen
  227.           interface has been generalized to allow any variable to be tied to
  228.           an object class which defines its access methods.
  229.  
  230.      +o Subroutine definitions may now be autoloaded
  231.           In fact, the AUTOLOAD mechanism also allows you to define any
  232.           arbitrary semantics for undefined subroutine calls.  It's not for
  233.           just autoloading.
  234.  
  235.      +o Regular expression enhancements
  236.           You can now specify nongreedy quantifiers.  You can now do grouping
  237.           without creating a backreference.  You can now write regular
  238.           expressions with embedded whitespace and comments for readability.
  239.           A consistent extensibility mechanism has been added that is upwardly
  240.           compatible with all old regular expressions.
  241.  
  242.      +o Innumerable Unbundled Modules
  243.           The Comprehensive Perl Archive Network described in the _p_e_r_l_m_o_d_l_i_b
  244.           manpage contains hundreds of plug-and-play modules full of reusable
  245.           code.  See _h_t_t_p://_w_w_w._p_e_r_l._c_o_m/_C_P_A_N for a site near you.
  246.  
  247.      +o Compilability
  248.           While not yet in full production mode, a working perl-to-C compiler
  249.           does exist.  It can generate portable byte code, simple C, or
  250.           optimized C code.
  251.  
  252.      Okay, that's _d_e_f_i_n_i_t_e_l_y enough hype.
  253.  
  254. EEEENNNNVVVVIIIIRRRROOOONNNNMMMMEEEENNNNTTTT
  255.      See the _p_e_r_l_r_u_n manpage.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  269.  
  270.  
  271.  
  272. AAAAUUUUTTTTHHHHOOOORRRR
  273.      Larry Wall <_l_a_r_r_y@_w_a_l_l._o_r_g>, with the help of oodles of other folks.
  274.  
  275.      If your Perl success stories and testimonials may be of help to others
  276.      who wish to advocate the use of Perl in their applications, or if you
  277.      wish to simply express your gratitude to Larry and the Perl developers,
  278.      please write to <_p_e_r_l-_t_h_a_n_k_s@_p_e_r_l._o_r_g>.
  279.  
  280. FFFFIIIILLLLEEEESSSS
  281.       "@INC"                 locations of perl libraries
  282.  
  283.  
  284. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  285.       a2p    awk to perl translator
  286.  
  287.       s2p    sed to perl translator
  288.  
  289.  
  290. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  291.      The ----wwww switch produces some lovely diagnostics.
  292.  
  293.      See the _p_e_r_l_d_i_a_g manpage for explanations of all Perl's diagnostics.  The
  294.      use diagnostics pragma automatically turns Perl's normally terse warnings
  295.      and errors into these longer forms.
  296.  
  297.      Compilation errors will tell you the line number of the error, with an
  298.      indication of the next token or token type that was to be examined.  (In
  299.      the case of a script passed to Perl via ----eeee switches, each ----eeee is counted
  300.      as one line.)
  301.  
  302.      Setuid scripts have additional constraints that can produce error
  303.      messages such as "Insecure dependency".  See the _p_e_r_l_s_e_c manpage.
  304.  
  305.      Did we mention that you should definitely consider using the ----wwww switch?
  306.  
  307. IIIIRRRRIIIIXXXX SSSSPPPPEEEECCCCIIIIFFFFIIIICCCCSSSS
  308.      Perl is compiled with a shared libperl.so, which lives in the /_u_s_r/_l_i_b_3_2
  309.      directory. It is compiled with 5.003 compatibility on.
  310.  
  311.      Perl's standard library installs into /_u_s_r/_s_h_a_r_e/_l_i_b/_p_e_r_l_5/, which may be
  312.      NFS mounted read-only. In that case, and if you wish to install modules
  313.      locally, you should consider moving the /_u_s_r/_s_h_a_r_e/_l_i_b/_p_e_r_l_5/_s_i_t_e__p_e_r_l/
  314.      directory to some place on the local disk, and create a symlink.
  315.  
  316.      Perl is compiled ----nnnn33332222 ----mmmmiiiippppssss3333. If you have any compiled modules from an
  317.      older IRIX release, they are probably compiled ----33332222, and will have to be
  318.      recompiled before they will work. If your modules use libraries that are
  319.      not available in ----nnnn33332222, then you will need a version of perl compiled to
  320.      that ABI. You cannot link or load objects of different ABI. A version of
  321.      perl compiled ----33332222 is available via SGI Freeware (CDROM or various Web
  322.      locations).
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  335.  
  336.  
  337.  
  338.      Perl is compiled to use ddddrrrraaaannnndddd44448888(((()))) as Perl's rrrraaaannnndddd(((()))) function, instead of
  339.      the standard, weak PRNG.
  340.  
  341. BBBBUUUUGGGGSSSS
  342.      The ----wwww switch is not mandatory.
  343.  
  344.      Perl is at the mercy of your machine's definitions of various operations
  345.      such as type casting, _a_t_o_f(), and floating-point output with _s_p_r_i_n_t_f().
  346.  
  347.      If your stdio requires a seek or eof between reads and writes on a
  348.      particular stream, so does Perl.  (This doesn't apply to _s_y_s_r_e_a_d() and
  349.      _s_y_s_w_r_i_t_e().)
  350.  
  351.      While none of the built-in data types have any arbitrary size limits
  352.      (apart from memory size), there are still a few arbitrary limits:  a
  353.      given variable name may not be longer than 255 characters, and no
  354.      component of your PATH may be longer than 255 if you use ----SSSS.  A regular
  355.      expression may not compile to more than 32767 bytes internally.
  356.  
  357.      You may mail your bug reports (be sure to include full configuration
  358.      information as output by the myconfig program in the perl source tree, or
  359.      by perl -V) to <_p_e_r_l_b_u_g@_p_e_r_l._c_o_m>.  If you've succeeded in compiling
  360.      perl, the perlbug script in the utils/ subdirectory can be used to help
  361.      mail in a bug report.
  362.  
  363.      Perl actually stands for Pathologically Eclectic Rubbish Lister, but
  364.      don't tell anyone I said that.
  365.  
  366. NNNNOOOOTTTTEEEESSSS
  367.      The Perl motto is "There's more than one way to do it."  Divining how
  368.      many more is left as an exercise to the reader.
  369.  
  370.      The three principal virtues of a programmer are Laziness, Impatience, and
  371.      Hubris.  See the Camel Book for why.
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. PPPPEEEERRRRLLLL((((1111))))                                                                PPPPEEEERRRRLLLL((((1111))))
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.                                                                         PPPPaaaaggggeeee 7777
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.