home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 July / AMIGA_1996_7.BIN / ausgabe_7_96 / pd-programmierung / perl5_002bin.lha / man / catp / perlembed.0 < prev    next >
Text File  |  1996-03-02  |  72KB  |  859 lines

  1.  
  2.  
  3.  
  4. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  5.  
  6.  
  7. NNNNAAAAMMMMEEEE
  8.        perlembed - how to embed perl in your C program
  9.  
  10. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  11.        PPPPRRRREEEEAAAAMMMMBBBBLLLLEEEE
  12.  
  13.        Do you want to:
  14.  
  15.        UUUUsssseeee CCCC ffffrrrroooommmm PPPPeeeerrrrllll????
  16.             Read the _p_e_r_l_c_a_l_l manpage and the _p_e_r_l_x_s manpage.
  17.  
  18.        UUUUsssseeee aaaa UUUUNNNNIIIIXXXX pppprrrrooooggggrrrraaaammmm ffffrrrroooommmm PPPPeeeerrrrllll????
  19.             Read about backquotes and the ssssyyyysssstttteeeemmmm entry in the
  20.             _p_e_r_l_f_u_n_c manpage and the eeeexxxxeeeecccc entry in the _p_e_r_l_f_u_n_c
  21.             manpage.
  22.  
  23.        UUUUsssseeee PPPPeeeerrrrllll ffffrrrroooommmm PPPPeeeerrrrllll????
  24.             Read about the ddddoooo entry in the _p_e_r_l_f_u_n_c manpage and
  25.             the eeeevvvvaaaallll entry in the _p_e_r_l_f_u_n_c manpage and the uuuusssseeee
  26.             entry in the _p_e_r_l_m_o_d manpage and the rrrreeeeqqqquuuuiiiirrrreeee entry in
  27.             the _p_e_r_l_m_o_d manpage.
  28.  
  29.        UUUUsssseeee CCCC ffffrrrroooommmm CCCC????
  30.             Rethink your design.
  31.  
  32.        UUUUsssseeee PPPPeeeerrrrllll ffffrrrroooommmm CCCC????
  33.             Read on...
  34.  
  35.        RRRROOOOAAAADDDDMMMMAAAAPPPP
  36.  
  37.        the section on _C_o_m_p_i_l_i_n_g _y_o_u_r _C _p_r_o_g_r_a_m
  38.  
  39.        There's one example in each of the five sections:
  40.  
  41.        the section on _A_d_d_i_n_g _a _P_e_r_l _i_n_t_e_r_p_r_e_t_e_r _t_o _y_o_u_r _C _p_r_o_g_r_a_m
  42.  
  43.        the section on _C_a_l_l_i_n_g _a _P_e_r_l _s_u_b_r_o_u_t_i_n_e _f_r_o_m _y_o_u_r _C
  44.        _p_r_o_g_r_a_m
  45.  
  46.        the section on _E_v_a_l_u_a_t_i_n_g _a _P_e_r_l _s_t_a_t_e_m_e_n_t _f_r_o_m _y_o_u_r _C
  47.        _p_r_o_g_r_a_m
  48.  
  49.        the section on _P_e_r_f_o_r_m_i_n_g _P_e_r_l _p_a_t_t_e_r_n _m_a_t_c_h_e_s _a_n_d
  50.        _s_u_b_s_t_i_t_u_t_i_o_n_s _f_r_o_m _y_o_u_r _C _p_r_o_g_r_a_m
  51.  
  52.        the section on _F_i_d_d_l_i_n_g _w_i_t_h _t_h_e _P_e_r_l _s_t_a_c_k _f_r_o_m _y_o_u_r _C
  53.        _p_r_o_g_r_a_m
  54.  
  55.        This documentation is UNIX specific.
  56.  
  57.        CCCCoooommmmppppiiiilllliiiinnnngggg yyyyoooouuuurrrr CCCC pppprrrrooooggggrrrraaaammmm
  58.  
  59.        Every C program that uses Perl must link in the _p_e_r_l
  60.        _l_i_b_r_a_r_y.
  61.  
  62.  
  63.  
  64. 30/Jan/96                perl 5.002 with                        1
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  71.  
  72.  
  73.        What's that, you ask?  Perl is itself written in C; the
  74.        perl library is the collection of compiled C programs that
  75.        were used to create your perl executable (_/_u_s_r_/_b_i_n_/_p_e_r_l or
  76.        equivalent).  (Corollary: you can't use Perl from your C
  77.        program unless Perl has been compiled on your machine, or
  78.        installed properly--that's why you shouldn't blithely copy
  79.        Perl executables from machine to machine without also
  80.        copying the _l_i_b directory.)
  81.  
  82.        Your C program will--usually--allocate, "run", and
  83.        deallocate a _P_e_r_l_I_n_t_e_r_p_r_e_t_e_r object, which is defined in
  84.        the perl library.
  85.  
  86.        If your copy of Perl is recent enough to contain this
  87.        documentation (5.002 or later), then the perl library (and
  88.        _E_X_T_E_R_N_._h and _p_e_r_l_._h, which you'll also need) will reside
  89.        in a directory resembling this:
  90.  
  91.            ////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////yyyyoooouuuurrrr____aaaarrrrcccchhhhiiiitttteeeeccccttttuuuurrrreeee____hhhheeeerrrreeee////CCCCOOOORRRREEEE
  92.  
  93.        or perhaps just
  94.  
  95.            ////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////CCCCOOOORRRREEEE
  96.  
  97.        or maybe something like
  98.  
  99.            ////uuuussssrrrr////oooopppptttt////ppppeeeerrrrllll5555////CCCCOOOORRRREEEE
  100.  
  101.        Execute this statement for a hint about where to find
  102.        CORE:
  103.  
  104.            ppppeeeerrrrllll ----eeee ''''uuuusssseeee CCCCoooonnnnffffiiiigggg;;;; pppprrrriiiinnnntttt $$$$CCCCoooonnnnffffiiiigggg{{{{aaaarrrrcccchhhhlllliiiibbbb}}}}''''
  105.  
  106.        Here's how you might compile the example in the next
  107.        section, the section on _A_d_d_i_n_g _a _P_e_r_l _i_n_t_e_r_p_r_e_t_e_r _t_o _y_o_u_r
  108.        _C _p_r_o_g_r_a_m, on a DEC Alpha running the OSF operating
  109.        system:
  110.  
  111.            %%%% cccccccc ----oooo iiiinnnntttteeeerrrrpppp iiiinnnntttteeeerrrrpppp....cccc ----LLLL////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE
  112.            ----IIII////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE ----llllppppeeeerrrrllll ----llllmmmm
  113.  
  114.        You'll have to choose the appropriate compiler (_c_c, _g_c_c,
  115.        et al.)  and library directory (_/_u_s_r_/_l_o_c_a_l_/_l_i_b_/_._._.)  for
  116.        your machine.  If your compiler complains that certain
  117.        functions are undefined, or that it can't locate _-_l_p_e_r_l,
  118.        then you need to change the path following the -L.  If it
  119.        complains that it can't find _E_X_T_E_R_N_._h or _p_e_r_l_._h, you need
  120.        to change the path following the -I.
  121.  
  122.        You may have to add extra libraries as well.  Which ones?
  123.        Perhaps those printed by
  124.  
  125.           ppppeeeerrrrllll ----eeee ''''uuuusssseeee CCCCoooonnnnffffiiiigggg;;;; pppprrrriiiinnnntttt $$$$CCCCoooonnnnffffiiiigggg{{{{lllliiiibbbbssss}}}}''''
  126.  
  127.  
  128.  
  129.  
  130. 30/Jan/96                perl 5.002 with                        2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  137.  
  138.  
  139.        AAAAddddddddiiiinnnngggg aaaa PPPPeeeerrrrllll iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr ttttoooo yyyyoooouuuurrrr CCCC pppprrrrooooggggrrrraaaammmm
  140.  
  141.        In a sense, perl (the C program) is a good example of
  142.        embedding Perl (the language), so I'll demonstrate
  143.        embedding with _m_i_n_i_p_e_r_l_m_a_i_n_._c, from the source
  144.        distribution.  Here's a bastardized, non-portable version
  145.        of _m_i_n_i_p_e_r_l_m_a_i_n_._c containing the essentials of embedding:
  146.  
  147.            ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  148.            ####iiiinnnncccclllluuuuddddeeee <<<<EEEEXXXXTTTTEEEERRRRNNNN....hhhh>>>>               ////**** ffffrrrroooommmm tttthhhheeee PPPPeeeerrrrllll ddddiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn     ****////
  149.            ####iiiinnnncccclllluuuuddddeeee <<<<ppppeeeerrrrllll....hhhh>>>>                 ////**** ffffrrrroooommmm tttthhhheeee PPPPeeeerrrrllll ddddiiiissssttttrrrriiiibbbbuuuuttttiiiioooonnnn     ****////
  150.  
  151.            ssssttttaaaattttiiiicccc PPPPeeeerrrrllllIIIInnnntttteeeerrrrpppprrrreeeetttteeeerrrr ****mmmmyyyy____ppppeeeerrrrllll;;;;  ////************    TTTThhhheeee PPPPeeeerrrrllll iiiinnnntttteeeerrrrpppprrrreeeetttteeeerrrr    ************////
  152.  
  153.            iiiinnnntttt mmmmaaaaiiiinnnn((((iiiinnnntttt aaaarrrrggggcccc,,,, cccchhhhaaaarrrr ********aaaarrrrggggvvvv,,,, cccchhhhaaaarrrr ********eeeennnnvvvv))))
  154.            {{{{
  155.                mmmmyyyy____ppppeeeerrrrllll ==== ppppeeeerrrrllll____aaaalllllllloooocccc(((())));;;;
  156.                ppppeeeerrrrllll____ccccoooonnnnssssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  157.                ppppeeeerrrrllll____ppppaaaarrrrsssseeee((((mmmmyyyy____ppppeeeerrrrllll,,,, NNNNUUUULLLLLLLL,,,, aaaarrrrggggcccc,,,, aaaarrrrggggvvvv,,,, eeeennnnvvvv))));;;;
  158.                ppppeeeerrrrllll____rrrruuuunnnn((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  159.                ppppeeeerrrrllll____ddddeeeessssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  160.                ppppeeeerrrrllll____ffffrrrreeeeeeee((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  161.            }}}}
  162.  
  163.        Now compile this program (I'll call it _i_n_t_e_r_p_._c) into an
  164.        executable:
  165.  
  166.            %%%% cccccccc ----oooo iiiinnnntttteeeerrrrpppp iiiinnnntttteeeerrrrpppp....cccc ----LLLL////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE
  167.            ----IIII////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE ----llllppppeeeerrrrllll ----llllmmmm
  168.  
  169.        After a successful compilation, you'll be able to use
  170.        _i_n_t_e_r_p just like perl itself:
  171.  
  172.            %%%% iiiinnnntttteeeerrrrpppp
  173.            pppprrrriiiinnnntttt """"PPPPrrrreeeettttttttyyyy GGGGoooooooodddd PPPPeeeerrrrllll \\\\nnnn"""";;;;
  174.            pppprrrriiiinnnntttt """"11110000888899990000 ---- 9999888800001111 iiiissss """",,,, 11110000888899990000 ---- 9999888800001111;;;;
  175.            <<<<CCCCTTTTRRRRLLLL----DDDD>>>>
  176.            PPPPrrrreeeettttttttyyyy GGGGoooooooodddd PPPPeeeerrrrllll
  177.            11110000888899990000 ---- 9999888800001111 iiiissss 1111000088889999
  178.  
  179.        or
  180.  
  181.            %%%% iiiinnnntttteeeerrrrpppp ----eeee ''''pppprrrriiiinnnnttttffff((((""""%%%%xxxx"""",,,, 3333777733335555999922228888555555559999))))''''
  182.            ddddeeeeaaaaddddbbbbeeeeeeeeffff
  183.  
  184.        You can also read and execute Perl statements from a file
  185.        while in the midst of your C program, by placing the
  186.        filename in _a_r_g_v_[_1_] before calling _p_e_r_l___r_u_n_(_).
  187.  
  188.        CCCCaaaalllllllliiiinnnngggg aaaa PPPPeeeerrrrllll ssssuuuubbbbrrrroooouuuuttttiiiinnnneeee ffffrrrroooommmm yyyyoooouuuurrrr CCCC pppprrrrooooggggrrrraaaammmm
  189.  
  190.        To call individual Perl subroutines, you'll need to remove
  191.        the call to _p_e_r_l___r_u_n_(_) and replace it with a call to
  192.        _p_e_r_l___c_a_l_l___a_r_g_v_(_).
  193.  
  194.  
  195.  
  196. 30/Jan/96                perl 5.002 with                        3
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  203.  
  204.  
  205.        That's shown below, in a program I'll call _s_h_o_w_t_i_m_e_._c.
  206.  
  207.            ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  208.            ####iiiinnnncccclllluuuuddddeeee <<<<EEEEXXXXTTTTEEEERRRRNNNN....hhhh>>>>
  209.            ####iiiinnnncccclllluuuuddddeeee <<<<ppppeeeerrrrllll....hhhh>>>>
  210.  
  211.            ssssttttaaaattttiiiicccc PPPPeeeerrrrllllIIIInnnntttteeeerrrrpppprrrreeeetttteeeerrrr ****mmmmyyyy____ppppeeeerrrrllll;;;;
  212.  
  213.            iiiinnnntttt mmmmaaaaiiiinnnn((((iiiinnnntttt aaaarrrrggggcccc,,,, cccchhhhaaaarrrr ********aaaarrrrggggvvvv,,,, cccchhhhaaaarrrr ********eeeennnnvvvv))))
  214.            {{{{
  215.                mmmmyyyy____ppppeeeerrrrllll ==== ppppeeeerrrrllll____aaaalllllllloooocccc(((())));;;;
  216.                ppppeeeerrrrllll____ccccoooonnnnssssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  217.  
  218.                ppppeeeerrrrllll____ppppaaaarrrrsssseeee((((mmmmyyyy____ppppeeeerrrrllll,,,, NNNNUUUULLLLLLLL,,,, aaaarrrrggggcccc,,,, aaaarrrrggggvvvv,,,, eeeennnnvvvv))));;;;
  219.  
  220.                                             ////************ TTTThhhhiiiissss rrrreeeeppppllllaaaacccceeeessss ppppeeeerrrrllll____rrrruuuunnnn(((()))) ************////
  221.                ppppeeeerrrrllll____ccccaaaallllllll____aaaarrrrggggvvvv((((""""sssshhhhoooowwwwttttiiiimmmmeeee"""",,,, GGGG____DDDDIIIISSSSCCCCAAAARRRRDDDD |||| GGGG____NNNNOOOOAAAARRRRGGGGSSSS,,,, aaaarrrrggggvvvv))));;;;
  222.                ppppeeeerrrrllll____ddddeeeessssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  223.                ppppeeeerrrrllll____ffffrrrreeeeeeee((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  224.            }}}}
  225.  
  226.        where _s_h_o_w_t_i_m_e is a Perl subroutine that takes no
  227.        arguments (that's the _G___N_O_A_R_G_S) and for which I'll ignore
  228.        the return value (that's the _G___D_I_S_C_A_R_D).  Those flags, and
  229.        others, are discussed in the _p_e_r_l_c_a_l_l manpage.
  230.  
  231.        I'll define the _s_h_o_w_t_i_m_e subroutine in a file called
  232.        _s_h_o_w_t_i_m_e_._p_l:
  233.  
  234.            pppprrrriiiinnnntttt """"IIII sssshhhhaaaannnn''''tttt bbbbeeee pppprrrriiiinnnntttteeeedddd...."""";;;;
  235.  
  236.            ssssuuuubbbb sssshhhhoooowwwwttttiiiimmmmeeee {{{{
  237.                pppprrrriiiinnnntttt ttttiiiimmmmeeee;;;;
  238.            }}}}
  239.  
  240.        Simple enough.  Now compile and run:
  241.  
  242.            %%%% cccccccc ----oooo sssshhhhoooowwwwttttiiiimmmmeeee sssshhhhoooowwwwttttiiiimmmmeeee....cccc ----LLLL////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE
  243.            ----IIII////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE ----llllppppeeeerrrrllll ----llllmmmm
  244.  
  245.            %%%% sssshhhhoooowwwwttttiiiimmmmeeee sssshhhhoooowwwwttttiiiimmmmeeee....ppppllll
  246.            888811118888222288884444555599990000
  247.  
  248.        yielding the number of seconds that elapsed between
  249.        January 1, 1970 (the beginning of the UNIX epoch), and the
  250.        moment I began writing this sentence.
  251.  
  252.        If you want to pass some arguments to the Perl subroutine,
  253.        or you want to access the return value, you'll need to
  254.        manipulate the Perl stack, demonstrated in the last
  255.        section of this document: the section on _F_i_d_d_l_i_n_g _w_i_t_h _t_h_e
  256.        _P_e_r_l _s_t_a_c_k _f_r_o_m _y_o_u_r _C _p_r_o_g_r_a_m
  257.  
  258.  
  259.  
  260.  
  261.  
  262. 30/Jan/96                perl 5.002 with                        4
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  269.  
  270.  
  271.        EEEEvvvvaaaalllluuuuaaaattttiiiinnnngggg aaaa PPPPeeeerrrrllll ssssttttaaaatttteeeemmmmeeeennnntttt ffffrrrroooommmm yyyyoooouuuurrrr CCCC pppprrrrooooggggrrrraaaammmm
  272.  
  273.        NOTE: This section, and the next, employ some very brittle
  274.        techniques for evaluting strings of Perl code.  Perl 5.002
  275.        contains some nifty features that enable A Better Way
  276.        (such as with the ppppeeeerrrrllll____eeeevvvvaaaallll____ssssvvvv entry in the _p_e_r_l_g_u_t_s
  277.        manpage).  Look for updates to this document soon.
  278.  
  279.        One way to evaluate a Perl string is to define a function
  280.        (we'll call ours _p_e_r_l___e_v_a_l_(_)) that wraps around Perl's the
  281.        eeeevvvvaaaallll entry in the _p_e_r_l_f_u_n_c manpage.
  282.  
  283.        Arguably, this is the only routine you'll ever need to
  284.        execute snippets of Perl code from within your C program.
  285.        Your string can be as long as you wish; it can contain
  286.        multiple statements; it can use the rrrreeeeqqqquuuuiiiirrrreeee entry in the
  287.        _p_e_r_l_m_o_d manpage or the ddddoooo entry in the _p_e_r_l_f_u_n_c manpage to
  288.        include external Perl files.
  289.  
  290.        Our _p_e_r_l___e_v_a_l_(_) lets us evaluate individual Perl strings,
  291.        and then extract variables for coercion into C types.  The
  292.        following program, _s_t_r_i_n_g_._c, executes three Perl strings,
  293.        extracting an iiiinnnntttt from the first, a ffffllllooooaaaatttt from the second,
  294.        and a cccchhhhaaaarrrr **** from the third.
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328. 30/Jan/96                perl 5.002 with                        5
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  335.  
  336.  
  337.           ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  338.           ####iiiinnnncccclllluuuuddddeeee <<<<EEEEXXXXTTTTEEEERRRRNNNN....hhhh>>>>
  339.           ####iiiinnnncccclllluuuuddddeeee <<<<ppppeeeerrrrllll....hhhh>>>>
  340.  
  341.           ssssttttaaaattttiiiicccc PPPPeeeerrrrllllIIIInnnntttteeeerrrrpppprrrreeeetttteeeerrrr ****mmmmyyyy____ppppeeeerrrrllll;;;;
  342.  
  343.           iiiinnnntttt ppppeeeerrrrllll____eeeevvvvaaaallll((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg))))
  344.           {{{{
  345.             cccchhhhaaaarrrr ****aaaarrrrggggvvvv[[[[2222]]]];;;;
  346.             aaaarrrrggggvvvv[[[[0000]]]] ==== ssssttttrrrriiiinnnngggg;;;;
  347.             aaaarrrrggggvvvv[[[[1111]]]] ==== NNNNUUUULLLLLLLL;;;;
  348.             ppppeeeerrrrllll____ccccaaaallllllll____aaaarrrrggggvvvv((((""""____eeeevvvvaaaallll____"""",,,, 0000,,,, aaaarrrrggggvvvv))));;;;
  349.           }}}}
  350.  
  351.           mmmmaaaaiiiinnnn ((((iiiinnnntttt aaaarrrrggggcccc,,,, cccchhhhaaaarrrr ********aaaarrrrggggvvvv,,,, cccchhhhaaaarrrr ********eeeennnnvvvv))))
  352.           {{{{
  353.             cccchhhhaaaarrrr ****eeeemmmmbbbbeeeeddddddddiiiinnnngggg[[[[]]]] ==== {{{{ """""""",,,, """"----eeee"""",,,, """"ssssuuuubbbb ____eeeevvvvaaaallll____ {{{{ eeeevvvvaaaallll $$$$____[[[[0000]]]] }}}}"""" }}}};;;;
  354.             SSSSTTTTRRRRLLLLEEEENNNN lllleeeennnnggggtttthhhh;;;;
  355.  
  356.             mmmmyyyy____ppppeeeerrrrllll ==== ppppeeeerrrrllll____aaaalllllllloooocccc(((())));;;;
  357.             ppppeeeerrrrllll____ccccoooonnnnssssttttrrrruuuucccctttt(((( mmmmyyyy____ppppeeeerrrrllll ))));;;;
  358.  
  359.             ppppeeeerrrrllll____ppppaaaarrrrsssseeee((((mmmmyyyy____ppppeeeerrrrllll,,,, NNNNUUUULLLLLLLL,,,, 3333,,,, eeeemmmmbbbbeeeeddddddddiiiinnnngggg,,,, eeeennnnvvvv))));;;;
  360.  
  361.                                               ////******** TTTTrrrreeeeaaaatttt $$$$aaaa aaaassss aaaannnn iiiinnnntttteeeeggggeeeerrrr ********////
  362.             ppppeeeerrrrllll____eeeevvvvaaaallll((((""""$$$$aaaa ==== 3333;;;; $$$$aaaa ********==== 2222""""))));;;;
  363.             pppprrrriiiinnnnttttffff((((""""aaaa ==== %%%%dddd\\\\nnnn"""",,,, SSSSvvvvIIIIVVVV((((ppppeeeerrrrllll____ggggeeeetttt____ssssvvvv((((""""aaaa"""",,,, FFFFAAAALLLLSSSSEEEE))))))))))));;;;
  364.  
  365.                                               ////******** TTTTrrrreeeeaaaatttt $$$$aaaa aaaassss aaaa ffffllllooooaaaatttt ********////
  366.             ppppeeeerrrrllll____eeeevvvvaaaallll((((""""$$$$aaaa ==== 3333....11114444;;;; $$$$aaaa ********==== 2222""""))));;;;
  367.             pppprrrriiiinnnnttttffff((((""""aaaa ==== %%%%ffff\\\\nnnn"""",,,, SSSSvvvvNNNNVVVV((((ppppeeeerrrrllll____ggggeeeetttt____ssssvvvv((((""""aaaa"""",,,, FFFFAAAALLLLSSSSEEEE))))))))))));;;;
  368.  
  369.                                               ////******** TTTTrrrreeeeaaaatttt $$$$aaaa aaaassss aaaa ssssttttrrrriiiinnnngggg ********////
  370.             ppppeeeerrrrllll____eeeevvvvaaaallll((((""""$$$$aaaa ==== ''''rrrreeeekkkkccccaaaaHHHH llllrrrreeeePPPP rrrreeeehhhhttttoooonnnnAAAA ttttssssuuuuJJJJ'''';;;; $$$$aaaa ==== rrrreeeevvvveeeerrrrsssseeee(((($$$$aaaa))));;;; """"))));;;;
  371.             pppprrrriiiinnnnttttffff((((""""aaaa ==== %%%%ssss\\\\nnnn"""",,,, SSSSvvvvPPPPVVVV((((ppppeeeerrrrllll____ggggeeeetttt____ssssvvvv((((""""aaaa"""",,,, FFFFAAAALLLLSSSSEEEE)))),,,, lllleeeennnnggggtttthhhh))))))));;;;
  372.  
  373.             ppppeeeerrrrllll____ddddeeeessssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  374.             ppppeeeerrrrllll____ffffrrrreeeeeeee((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  375.           }}}}
  376.  
  377.        All of those strange functions with _s_v in their names help
  378.        convert Perl scalars to C types.  They're described in the
  379.        _p_e_r_l_g_u_t_s manpage.
  380.  
  381.        If you compile and run _s_t_r_i_n_g_._c, you'll see the results of
  382.        using _S_v_I_V_(_) to create an iiiinnnntttt, _S_v_N_V_(_) to create a ffffllllooooaaaatttt,
  383.        and _S_v_P_V_(_) to create a string:
  384.  
  385.           aaaa ==== 9999
  386.           aaaa ==== 9999....888855559999666600000000
  387.           aaaa ==== JJJJuuuusssstttt AAAAnnnnooootttthhhheeeerrrr PPPPeeeerrrrllll HHHHaaaacccckkkkeeeerrrr
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394. 30/Jan/96                perl 5.002 with                        6
  395.  
  396.  
  397.  
  398.  
  399.  
  400. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  401.  
  402.  
  403.        PPPPeeeerrrrffffoooorrrrmmmmiiiinnnngggg PPPPeeeerrrrllll ppppaaaatttttttteeeerrrrnnnn mmmmaaaattttcccchhhheeeessss aaaannnndddd ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnnssss ffffrrrroooommmm
  404.        yyyyoooouuuurrrr CCCC pppprrrrooooggggrrrraaaammmm
  405.  
  406.        Our _p_e_r_l___e_v_a_l_(_) lets us evaluate strings of Perl code, so
  407.        we can define some functions that use it to "specialize"
  408.        in matches and substitutions: _m_a_t_c_h_(_), _s_u_b_s_t_i_t_u_t_e_(_), and
  409.        _m_a_t_c_h_e_s_(_).
  410.  
  411.           cccchhhhaaaarrrr mmmmaaaattttcccchhhh((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg,,,, cccchhhhaaaarrrr ****ppppaaaatttttttteeeerrrrnnnn))));;;;
  412.  
  413.        Given a string and a pattern (e.g. "m/clasp/" or
  414.        "/\b\w*\b/", which in your program might be represented as
  415.        """"////\\\\\\\\bbbb\\\\\\\\wwww****\\\\\\\\bbbb////""""), returns 1 if the string matches the
  416.        pattern and 0 otherwise.
  417.  
  418.           iiiinnnntttt ssssuuuubbbbssssttttiiiittttuuuutttteeee((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg[[[[]]]],,,, cccchhhhaaaarrrr ****ppppaaaatttttttteeeerrrrnnnn))));;;;
  419.  
  420.        Given a pointer to a string and an "=~" operation (e.g.
  421.        "s/bob/robert/g" or "tr[A-Z][a-z]"), modifies the string
  422.        according to the operation, returning the number of
  423.        substitutions made.
  424.  
  425.           iiiinnnntttt mmmmaaaattttcccchhhheeeessss((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg,,,, cccchhhhaaaarrrr ****ppppaaaatttttttteeeerrrrnnnn,,,, cccchhhhaaaarrrr ********mmmmaaaattttcccchhhheeeessss[[[[]]]]))));;;;
  426.  
  427.        Given a string, a pattern, and a pointer to an empty array
  428.        of strings, evaluates $$$$ssssttttrrrriiiinnnngggg ====~~~~ $$$$ppppaaaatttttttteeeerrrrnnnn in an array
  429.        context, and fills in _m_a_t_c_h_e_s with the array elements
  430.        (allocating memory as it does so), returning the number of
  431.        matches found.
  432.  
  433.        Here's a sample program, _m_a_t_c_h_._c, that uses all three:
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460. 30/Jan/96                perl 5.002 with                        7
  461.  
  462.  
  463.  
  464.  
  465.  
  466. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  467.  
  468.  
  469.           ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  470.           ####iiiinnnncccclllluuuuddddeeee <<<<EEEEXXXXTTTTEEEERRRRNNNN....hhhh>>>>
  471.           ####iiiinnnncccclllluuuuddddeeee <<<<ppppeeeerrrrllll....hhhh>>>>
  472.  
  473.           ssssttttaaaattttiiiicccc PPPPeeeerrrrllllIIIInnnntttteeeerrrrpppprrrreeeetttteeeerrrr ****mmmmyyyy____ppppeeeerrrrllll;;;;
  474.  
  475.           iiiinnnntttt eeeevvvvaaaallll((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg))))
  476.           {{{{
  477.             cccchhhhaaaarrrr ****aaaarrrrggggvvvv[[[[2222]]]];;;;
  478.             aaaarrrrggggvvvv[[[[0000]]]] ==== ssssttttrrrriiiinnnngggg;;;;
  479.             aaaarrrrggggvvvv[[[[1111]]]] ==== NNNNUUUULLLLLLLL;;;;
  480.             ppppeeeerrrrllll____ccccaaaallllllll____aaaarrrrggggvvvv((((""""____eeeevvvvaaaallll____"""",,,, 0000,,,, aaaarrrrggggvvvv))));;;;
  481.           }}}}
  482.  
  483.           ////******** mmmmaaaattttcccchhhh((((ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn))))
  484.            ********
  485.            ******** UUUUsssseeeedddd ffffoooorrrr mmmmaaaattttcccchhhheeeessss iiiinnnn aaaa ssssccccaaaallllaaaarrrr ccccoooonnnntttteeeexxxxtttt....
  486.            ********
  487.            ******** RRRReeeettttuuuurrrrnnnnssss 1111 iiiiffff tttthhhheeee mmmmaaaattttcccchhhh wwwwaaaassss ssssuuuucccccccceeeessssssssffffuuuullll;;;; 0000 ooootttthhhheeeerrrrwwwwiiiisssseeee....
  488.            ********////
  489.           cccchhhhaaaarrrr mmmmaaaattttcccchhhh((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg,,,, cccchhhhaaaarrrr ****ppppaaaatttttttteeeerrrrnnnn))))
  490.           {{{{
  491.             cccchhhhaaaarrrr ****ccccoooommmmmmmmaaaannnndddd;;;;
  492.             ccccoooommmmmmmmaaaannnndddd ==== mmmmaaaalllllllloooocccc((((ssssiiiizzzzeeeeooooffff((((cccchhhhaaaarrrr)))) **** ssssttttrrrrlllleeeennnn((((ssssttttrrrriiiinnnngggg)))) ++++ ssssttttrrrrlllleeeennnn((((ppppaaaatttttttteeeerrrrnnnn)))) ++++ 33337777))));;;;
  493.             sssspppprrrriiiinnnnttttffff((((ccccoooommmmmmmmaaaannnndddd,,,, """"$$$$ssssttttrrrriiiinnnngggg ==== ''''%%%%ssss'''';;;; $$$$rrrreeeettttuuuurrrrnnnn ==== $$$$ssssttttrrrriiiinnnngggg ====~~~~ %%%%ssss"""",,,,
  494.                ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn))));;;;
  495.             ppppeeeerrrrllll____eeeevvvvaaaallll((((ccccoooommmmmmmmaaaannnndddd))));;;;
  496.             ffffrrrreeeeeeee((((ccccoooommmmmmmmaaaannnndddd))));;;;
  497.             rrrreeeettttuuuurrrrnnnn SSSSvvvvIIIIVVVV((((ppppeeeerrrrllll____ggggeeeetttt____ssssvvvv((((""""rrrreeeettttuuuurrrrnnnn"""",,,, FFFFAAAALLLLSSSSEEEE))))))));;;;
  498.           }}}}
  499.  
  500.           ////******** ssssuuuubbbbssssttttiiiittttuuuutttteeee((((ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn))))
  501.            ********
  502.            ******** UUUUsssseeeedddd ffffoooorrrr ====~~~~ ooooppppeeeerrrraaaattttiiiioooonnnnssss tttthhhhaaaatttt mmmmooooddddiiiiffffyyyy tttthhhheeeeiiiirrrr lllleeeefffftttt----hhhhaaaannnndddd ssssiiiiddddeeee ((((ssss//////////// aaaannnndddd ttttrrrr////////////))))
  503.            ********
  504.            ******** RRRReeeettttuuuurrrrnnnnssss tttthhhheeee nnnnuuuummmmbbbbeeeerrrr ooooffff ssssuuuucccccccceeeessssssssffffuuuullll mmmmaaaattttcccchhhheeeessss,,,, aaaannnndddd
  505.            ******** mmmmooooddddiiiiffffiiiieeeessss tttthhhheeee iiiinnnnppppuuuutttt ssssttttrrrriiiinnnngggg iiiiffff tttthhhheeeerrrreeee wwwweeeerrrreeee aaaannnnyyyy....
  506.            ********////
  507.           iiiinnnntttt ssssuuuubbbbssssttttiiiittttuuuutttteeee((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg[[[[]]]],,,, cccchhhhaaaarrrr ****ppppaaaatttttttteeeerrrrnnnn))))
  508.           {{{{
  509.             cccchhhhaaaarrrr ****ccccoooommmmmmmmaaaannnndddd;;;;
  510.             SSSSTTTTRRRRLLLLEEEENNNN lllleeeennnnggggtttthhhh;;;;
  511.             ccccoooommmmmmmmaaaannnndddd ==== mmmmaaaalllllllloooocccc((((ssssiiiizzzzeeeeooooffff((((cccchhhhaaaarrrr)))) **** ssssttttrrrrlllleeeennnn((((****ssssttttrrrriiiinnnngggg)))) ++++ ssssttttrrrrlllleeeennnn((((ppppaaaatttttttteeeerrrrnnnn)))) ++++ 33335555))));;;;
  512.             sssspppprrrriiiinnnnttttffff((((ccccoooommmmmmmmaaaannnndddd,,,, """"$$$$ssssttttrrrriiiinnnngggg ==== ''''%%%%ssss'''';;;; $$$$rrrreeeetttt ==== (((($$$$ssssttttrrrriiiinnnngggg ====~~~~ %%%%ssss))))"""",,,,
  513.                ****ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn))));;;;
  514.             ppppeeeerrrrllll____eeeevvvvaaaallll((((ccccoooommmmmmmmaaaannnndddd))));;;;
  515.             ffffrrrreeeeeeee((((ccccoooommmmmmmmaaaannnndddd))));;;;
  516.             ****ssssttttrrrriiiinnnngggg ==== SSSSvvvvPPPPVVVV((((ppppeeeerrrrllll____ggggeeeetttt____ssssvvvv((((""""ssssttttrrrriiiinnnngggg"""",,,, FFFFAAAALLLLSSSSEEEE)))),,,, lllleeeennnnggggtttthhhh))));;;;
  517.             rrrreeeettttuuuurrrrnnnn SSSSvvvvIIIIVVVV((((ppppeeeerrrrllll____ggggeeeetttt____ssssvvvv((((""""rrrreeeetttt"""",,,, FFFFAAAALLLLSSSSEEEE))))))));;;;
  518.           }}}}
  519.  
  520.           ////******** mmmmaaaattttcccchhhheeeessss((((ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn,,,, mmmmaaaattttcccchhhheeeessss))))
  521.            ********
  522.            ******** UUUUsssseeeedddd ffffoooorrrr mmmmaaaattttcccchhhheeeessss iiiinnnn aaaannnn aaaarrrrrrrraaaayyyy ccccoooonnnntttteeeexxxxtttt....
  523.  
  524.  
  525.  
  526. 30/Jan/96                perl 5.002 with                        8
  527.  
  528.  
  529.  
  530.  
  531.  
  532. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  533.  
  534.  
  535.            ********
  536.            ******** RRRReeeettttuuuurrrrnnnnssss tttthhhheeee nnnnuuuummmmbbbbeeeerrrr ooooffff mmmmaaaattttcccchhhheeeessss,,,,
  537.            ******** aaaannnndddd ffffiiiillllllllssss iiiinnnn ********mmmmaaaattttcccchhhheeeessss wwwwiiiitttthhhh tttthhhheeee mmmmaaaattttcccchhhhiiiinnnngggg ssssuuuubbbbssssttttrrrriiiinnnnggggssss ((((aaaallllllllooooccccaaaatttteeeessss mmmmeeeemmmmoooorrrryyyy!!!!))))
  538.            ********////
  539.           iiiinnnntttt mmmmaaaattttcccchhhheeeessss((((cccchhhhaaaarrrr ****ssssttttrrrriiiinnnngggg,,,, cccchhhhaaaarrrr ****ppppaaaatttttttteeeerrrrnnnn,,,, cccchhhhaaaarrrr ********mmmmaaaattttcccchhhheeeessss[[[[]]]]))))
  540.           {{{{
  541.             cccchhhhaaaarrrr ****ccccoooommmmmmmmaaaannnndddd;;;;
  542.             SSSSVVVV ****ccccuuuurrrrrrrreeeennnntttt____mmmmaaaattttcccchhhh;;;;
  543.             AAAAVVVV ****aaaarrrrrrrraaaayyyy;;;;
  544.             IIII33332222 nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss;;;;
  545.             SSSSTTTTRRRRLLLLEEEENNNN lllleeeennnnggggtttthhhh;;;;
  546.             iiiinnnntttt iiii;;;;
  547.  
  548.             ccccoooommmmmmmmaaaannnndddd ==== mmmmaaaalllllllloooocccc((((ssssiiiizzzzeeeeooooffff((((cccchhhhaaaarrrr)))) **** ssssttttrrrrlllleeeennnn((((ssssttttrrrriiiinnnngggg)))) ++++ ssssttttrrrrlllleeeennnn((((ppppaaaatttttttteeeerrrrnnnn)))) ++++ 33338888))));;;;
  549.             sssspppprrrriiiinnnnttttffff((((ccccoooommmmmmmmaaaannnndddd,,,, """"$$$$ssssttttrrrriiiinnnngggg ==== ''''%%%%ssss'''';;;; @@@@aaaarrrrrrrraaaayyyy ==== (((($$$$ssssttttrrrriiiinnnngggg ====~~~~ %%%%ssss))))"""",,,,
  550.                ssssttttrrrriiiinnnngggg,,,, ppppaaaatttttttteeeerrrrnnnn))));;;;
  551.             ppppeeeerrrrllll____eeeevvvvaaaallll((((ccccoooommmmmmmmaaaannnndddd))));;;;
  552.             ffffrrrreeeeeeee((((ccccoooommmmmmmmaaaannnndddd))));;;;
  553.             aaaarrrrrrrraaaayyyy ==== ppppeeeerrrrllll____ggggeeeetttt____aaaavvvv((((""""aaaarrrrrrrraaaayyyy"""",,,, FFFFAAAALLLLSSSSEEEE))));;;;
  554.             nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss ==== aaaavvvv____lllleeeennnn((((aaaarrrrrrrraaaayyyy)))) ++++ 1111;;;; ////******** aaaassssssssuuuummmmeeee $$$$[[[[ iiiissss 0000 ********////
  555.             ****mmmmaaaattttcccchhhheeeessss ==== ((((cccchhhhaaaarrrr ********)))) mmmmaaaalllllllloooocccc((((ssssiiiizzzzeeeeooooffff((((cccchhhhaaaarrrr ****)))) **** nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss))));;;;
  556.             ffffoooorrrr ((((iiii ==== 0000;;;; iiii <<<<==== nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss;;;; iiii++++++++)))) {{{{
  557.               ccccuuuurrrrrrrreeeennnntttt____mmmmaaaattttcccchhhh ==== aaaavvvv____sssshhhhiiiifffftttt((((aaaarrrrrrrraaaayyyy))));;;;
  558.               ((((****mmmmaaaattttcccchhhheeeessss))))[[[[iiii]]]] ==== SSSSvvvvPPPPVVVV((((ccccuuuurrrrrrrreeeennnntttt____mmmmaaaattttcccchhhh,,,, lllleeeennnnggggtttthhhh))));;;;
  559.             }}}}
  560.             rrrreeeettttuuuurrrrnnnn nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss;;;;
  561.           }}}}
  562.  
  563.           mmmmaaaaiiiinnnn ((((iiiinnnntttt aaaarrrrggggcccc,,,, cccchhhhaaaarrrr ********aaaarrrrggggvvvv,,,, cccchhhhaaaarrrr ********eeeennnnvvvv))))
  564.           {{{{
  565.             cccchhhhaaaarrrr ****eeeemmmmbbbbeeeeddddddddiiiinnnngggg[[[[]]]] ==== {{{{ """""""",,,, """"----eeee"""",,,, """"ssssuuuubbbb ____eeeevvvvaaaallll____ {{{{ eeeevvvvaaaallll $$$$____[[[[0000]]]] }}}}"""" }}}};;;;
  566.             cccchhhhaaaarrrr ****tttteeeexxxxtttt,,,, ********mmmmaaaattttcccchhhheeeessss;;;;
  567.             iiiinnnntttt nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss,,,, iiii;;;;
  568.             iiiinnnntttt jjjj;;;;
  569.  
  570.             mmmmyyyy____ppppeeeerrrrllll ==== ppppeeeerrrrllll____aaaalllllllloooocccc(((())));;;;
  571.             ppppeeeerrrrllll____ccccoooonnnnssssttttrrrruuuucccctttt(((( mmmmyyyy____ppppeeeerrrrllll ))));;;;
  572.  
  573.             ppppeeeerrrrllll____ppppaaaarrrrsssseeee((((mmmmyyyy____ppppeeeerrrrllll,,,, NNNNUUUULLLLLLLL,,,, 3333,,,, eeeemmmmbbbbeeeeddddddddiiiinnnngggg,,,, eeeennnnvvvv))));;;;
  574.  
  575.             tttteeeexxxxtttt ==== ((((cccchhhhaaaarrrr ****)))) mmmmaaaalllllllloooocccc((((ssssiiiizzzzeeeeooooffff((((cccchhhhaaaarrrr)))) **** 444488886666))));;;; ////******** AAAA lllloooonnnngggg ssssttttrrrriiiinnnngggg ffffoooolllllllloooowwwwssss!!!! ********////
  576.             sssspppprrrriiiinnnnttttffff((((tttteeeexxxxtttt,,,, """"%%%%ssss"""",,,, """"WWWWhhhheeeennnn hhhheeee iiiissss aaaatttt aaaa ccccoooonnnnvvvveeeennnniiiieeeennnncccceeee ssssttttoooorrrreeee aaaannnndddd tttthhhheeee bbbbiiiillllllll ccccoooommmmeeeessss ttttoooo ssssoooommmmeeee aaaammmmoooouuuunnnntttt lllliiiikkkkeeee 77776666 cccceeeennnnttttssss,,,, MMMMaaaayyyynnnnaaaarrrrdddd iiiissss aaaawwwwaaaarrrreeee tttthhhhaaaatttt tttthhhheeeerrrreeee iiiissss ssssoooommmmeeeetttthhhhiiiinnnngggg hhhheeee ****sssshhhhoooouuuulllldddd**** ddddoooo,,,, ssssoooommmmeeeetttthhhhiiiinnnngggg tttthhhhaaaatttt wwwwiiiillllllll eeeennnnaaaabbbblllleeee hhhhiiiimmmm ttttoooo ggggeeeetttt bbbbaaaacccckkkk aaaa qqqquuuuaaaarrrrtttteeeerrrr,,,, bbbbuuuutttt hhhheeee hhhhaaaassss nnnnoooo iiiiddddeeeeaaaa ****wwwwhhhhaaaatttt****....  HHHHeeee ffffuuuummmmbbbblllleeeessss tttthhhhrrrroooouuuugggghhhh hhhhiiiissss rrrreeeedddd ssssqqqquuuueeeeeeeezzzzeeeeyyyy cccchhhhaaaannnnggggeeeeppppuuuurrrrsssseeee aaaannnndddd ggggiiiivvvveeeessss tttthhhheeee bbbbooooyyyy tttthhhhrrrreeeeeeee eeeexxxxttttrrrraaaa ppppeeeennnnnnnniiiieeeessss wwwwiiiitttthhhh hhhhiiiissss ddddoooollllllllaaaarrrr,,,, hhhhooooppppiiiinnnngggg tttthhhhaaaatttt hhhheeee mmmmiiiigggghhhhtttt lllluuuucccckkkk iiiinnnnttttoooo tttthhhheeee ccccoooorrrrrrrreeeecccctttt aaaammmmoooouuuunnnntttt....  TTTThhhheeee bbbbooooyyyy ggggiiiivvvveeeessss hhhhiiiimmmm bbbbaaaacccckkkk ttttwwwwoooo ooooffff hhhhiiiissss oooowwwwnnnn ppppeeeennnnnnnniiiieeeessss aaaannnndddd tttthhhheeeennnn tttthhhheeee bbbbiiiigggg sssshhhhiiiinnnnyyyy qqqquuuuaaaarrrrtttteeeerrrr tttthhhhaaaatttt iiiissss hhhhiiiissss pppprrrriiiizzzzeeee.... ----RRRRIIIICCCCHHHHHHHH""""))));;;;
  577.  
  578.             iiiiffff ((((ppppeeeerrrrllll____mmmmaaaattttcccchhhh((((tttteeeexxxxtttt,,,, """"mmmm////qqqquuuuaaaarrrrtttteeeerrrr////"""")))))))) ////******** DDDDooooeeeessss tttteeeexxxxtttt ccccoooonnnnttttaaaaiiiinnnn ''''qqqquuuuaaaarrrrtttteeeerrrr''''???? ********////
  579.               pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____mmmmaaaattttcccchhhh:::: TTTTeeeexxxxtttt ccccoooonnnnttttaaaaiiiinnnnssss tttthhhheeee wwwwoooorrrrdddd ''''qqqquuuuaaaarrrrtttteeeerrrr''''....\\\\nnnn\\\\nnnn""""))));;;;
  580.             eeeellllsssseeee
  581.               pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____mmmmaaaattttcccchhhh:::: TTTTeeeexxxxtttt ddddooooeeeessssnnnn''''tttt ccccoooonnnnttttaaaaiiiinnnn tttthhhheeee wwwwoooorrrrdddd ''''qqqquuuuaaaarrrrtttteeeerrrr''''....\\\\nnnn\\\\nnnn""""))));;;;
  582.  
  583.             iiiiffff ((((ppppeeeerrrrllll____mmmmaaaattttcccchhhh((((tttteeeexxxxtttt,,,, """"mmmm////eeeeiiiigggghhhhtttthhhh////"""")))))))) ////******** DDDDooooeeeessss tttteeeexxxxtttt ccccoooonnnnttttaaaaiiiinnnn ''''eeeeiiiigggghhhhtttthhhh''''???? ********////
  584.               pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____mmmmaaaattttcccchhhh:::: TTTTeeeexxxxtttt ccccoooonnnnttttaaaaiiiinnnnssss tttthhhheeee wwwwoooorrrrdddd ''''eeeeiiiigggghhhhtttthhhh''''....\\\\nnnn\\\\nnnn""""))));;;;
  585.             eeeellllsssseeee
  586.               pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____mmmmaaaattttcccchhhh:::: TTTTeeeexxxxtttt ddddooooeeeessssnnnn''''tttt ccccoooonnnnttttaaaaiiiinnnn tttthhhheeee wwwwoooorrrrdddd ''''eeeeiiiigggghhhhtttthhhh''''....\\\\nnnn\\\\nnnn""""))));;;;
  587.  
  588.                                               ////******** MMMMaaaattttcccchhhh aaaallllllll ooooccccccccuuuurrrrrrrreeeennnncccceeeessss ooooffff ////wwwwiiii........//// ********////
  589.  
  590.  
  591.  
  592. 30/Jan/96                perl 5.002 with                        9
  593.  
  594.  
  595.  
  596.  
  597.  
  598. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  599.  
  600.  
  601.             nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss ==== ppppeeeerrrrllll____mmmmaaaattttcccchhhheeeessss((((tttteeeexxxxtttt,,,, """"mmmm////((((wwwwiiii........))))////gggg"""",,,, &&&&mmmmaaaattttcccchhhheeeessss))));;;;
  602.  
  603.             pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____mmmmaaaattttcccchhhheeeessss:::: mmmm////((((wwwwiiii........))))////gggg ffffoooouuuunnnndddd %%%%dddd mmmmaaaattttcccchhhheeeessss............\\\\nnnn"""",,,, nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss))));;;;
  604.             ffffoooorrrr ((((iiii ==== 0000;;;; iiii <<<< nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss;;;; iiii++++++++))))
  605.               pppprrrriiiinnnnttttffff((((""""mmmmaaaattttcccchhhh:::: %%%%ssss\\\\nnnn"""",,,, mmmmaaaattttcccchhhheeeessss[[[[iiii]]]]))));;;;
  606.             pppprrrriiiinnnnttttffff((((""""\\\\nnnn""""))));;;;
  607.             ffffoooorrrr ((((iiii ==== 0000;;;; iiii <<<< nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss;;;; iiii++++++++)))) {{{{
  608.               ffffrrrreeeeeeee((((mmmmaaaattttcccchhhheeeessss[[[[iiii]]]]))));;;;
  609.             }}}}
  610.             ffffrrrreeeeeeee((((mmmmaaaattttcccchhhheeeessss))));;;;
  611.  
  612.                                               ////******** RRRReeeemmmmoooovvvveeee aaaallllllll vvvvoooowwwweeeellllssss ffffrrrroooommmm tttteeeexxxxtttt ********////
  613.             nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss ==== ppppeeeerrrrllll____ssssuuuubbbbssssttttiiiittttuuuutttteeee((((&&&&tttteeeexxxxtttt,,,, """"ssss////[[[[aaaaeeeeiiiioooouuuu]]]]////////ggggiiii""""))));;;;
  614.             iiiiffff ((((nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss)))) {{{{
  615.               pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____ssssuuuubbbbssssttttiiiittttuuuutttteeee:::: ssss////[[[[aaaaeeeeiiiioooouuuu]]]]////////ggggiiii............%%%%dddd ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnnssss mmmmaaaaddddeeee....\\\\nnnn"""",,,,
  616.                nnnnuuuummmm____mmmmaaaattttcccchhhheeeessss))));;;;
  617.               pppprrrriiiinnnnttttffff((((""""NNNNoooowwww tttteeeexxxxtttt iiiissss:::: %%%%ssss\\\\nnnn\\\\nnnn"""",,,, tttteeeexxxxtttt))));;;;
  618.             }}}}
  619.  
  620.                                               ////******** AAAAtttttttteeeemmmmpppptttt aaaa ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnn
  621.             iiiiffff ((((!!!!ppppeeeerrrrllll____ssssuuuubbbbssssttttiiiittttuuuutttteeee((((&&&&tttteeeexxxxtttt,,,, """"ssss////PPPPeeeerrrrllll////CCCC////"""")))))))) {{{{
  622.               pppprrrriiiinnnnttttffff((((""""ppppeeeerrrrllll____ssssuuuubbbbssssttttiiiittttuuuutttteeee:::: ssss////PPPPeeeerrrrllll////CCCC............NNNNoooo ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnn mmmmaaaaddddeeee....\\\\nnnn\\\\nnnn""""))));;;;
  623.             }}}}
  624.  
  625.             ffffrrrreeeeeeee((((tttteeeexxxxtttt))));;;;
  626.  
  627.             ppppeeeerrrrllll____ddddeeeessssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  628.             ppppeeeerrrrllll____ffffrrrreeeeeeee((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  629.           }}}}
  630.  
  631.        which produces the output
  632.  
  633.           ppppeeeerrrrllll____mmmmaaaattttcccchhhh:::: TTTTeeeexxxxtttt ccccoooonnnnttttaaaaiiiinnnnssss tttthhhheeee wwwwoooorrrrdddd ''''qqqquuuuaaaarrrrtttteeeerrrr''''....
  634.  
  635.           ppppeeeerrrrllll____mmmmaaaattttcccchhhh:::: TTTTeeeexxxxtttt ddddooooeeeessssnnnn''''tttt ccccoooonnnnttttaaaaiiiinnnn tttthhhheeee wwwwoooorrrrdddd ''''eeeeiiiigggghhhhtttthhhh''''....
  636.  
  637.           ppppeeeerrrrllll____mmmmaaaattttcccchhhheeeessss:::: mmmm////((((wwwwiiii........))))////gggg ffffoooouuuunnnndddd 2222 mmmmaaaattttcccchhhheeeessss............
  638.           mmmmaaaattttcccchhhh:::: wwwwiiiillllllll
  639.           mmmmaaaattttcccchhhh:::: wwwwiiiitttthhhh
  640.  
  641.           ppppeeeerrrrllll____ssssuuuubbbbssssttttiiiittttuuuutttteeee:::: ssss////[[[[aaaaeeeeiiiioooouuuu]]]]////////ggggiiii............111133339999 ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnnssss mmmmaaaaddddeeee....
  642.           NNNNoooowwww tttteeeexxxxtttt iiiissss:::: WWWWhhhhnnnn hhhh ssss tttt  ccccnnnnvvvvnnnnnnnncccc ssssttttrrrr nnnndddd tttthhhh bbbbllllllll ccccmmmmssss tttt ssssmmmm mmmmnnnntttt llllkkkk 77776666 ccccnnnnttttssss,,,, MMMMyyyynnnnrrrrdddd ssss wwwwrrrr tttthhhhtttt tttthhhhrrrr ssss ssssmmmmtttthhhhnnnngggg hhhh ****sssshhhhlllldddd**** dddd,,,, ssssmmmmtttthhhhnnnngggg tttthhhhtttt wwwwllllllll nnnnbbbbllll hhhhmmmm tttt ggggtttt bbbbcccckkkk  qqqqrrrrttttrrrr,,,, bbbbtttt hhhh hhhhssss nnnn dddd ****wwwwhhhhtttt****....  HHHH ffffmmmmbbbbllllssss tttthhhhrrrrgggghhhh hhhhssss rrrrdddd ssssqqqqzzzzyyyy cccchhhhnnnnggggpppprrrrssss nnnndddd ggggvvvvssss tttthhhh bbbbyyyy tttthhhhrrrr xxxxttttrrrr ppppnnnnnnnnssss wwwwtttthhhh hhhhssss ddddllllllllrrrr,,,, hhhhppppnnnngggg tttthhhhtttt hhhh mmmmgggghhhhtttt llllcccckkkk nnnntttt tttthhhh ccccrrrrrrrrcccctttt mmmmnnnntttt....  TTTThhhh bbbbyyyy ggggvvvvssss hhhhmmmm bbbbcccckkkk ttttwwww ffff hhhhssss wwwwnnnn ppppnnnnnnnnssss nnnndddd tttthhhhnnnn tttthhhh bbbbgggg sssshhhhnnnnyyyy qqqqrrrrttttrrrr tttthhhhtttt ssss hhhhssss pppprrrrzzzz.... ----RRRRCCCCHHHHHHHH
  643.  
  644.           ppppeeeerrrrllll____ssssuuuubbbbssssttttiiiittttuuuutttteeee:::: ssss////PPPPeeeerrrrllll////CCCC............NNNNoooo ssssuuuubbbbssssttttiiiittttuuuuttttiiiioooonnnn mmmmaaaaddddeeee....
  645.  
  646.        ====hhhheeeeaaaadddd2222 FFFFiiiiddddddddlllliiiinnnngggg wwwwiiiitttthhhh tttthhhheeee PPPPeeeerrrrllll ssssttttaaaacccckkkk ffffrrrroooommmm yyyyoooouuuurrrr CCCC pppprrrrooooggggrrrraaaammmm
  647.  
  648.        When trying to explain stacks, most computer science
  649.        textbooks mumble something about spring-loaded columns of
  650.        cafeteria plates: the last thing you pushed on the stack
  651.        is the first thing you pop off.  That'll do for our
  652.        purposes: your C program will push some arguments onto
  653.        "the Perl stack", shut its eyes while some magic happens,
  654.        and then pop the results--the return value of your Perl
  655.  
  656.  
  657.  
  658. 30/Jan/96                perl 5.002 with                       10
  659.  
  660.  
  661.  
  662.  
  663.  
  664. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  665.  
  666.  
  667.        subroutine--off the stack.
  668.  
  669.        First you'll need to know how to convert between C types
  670.        and Perl types, with _n_e_w_S_V_i_v_(_) and _s_v___s_e_t_n_v_(_) and _n_e_w_A_V_(_)
  671.        and all their friends.  They're described in the _p_e_r_l_g_u_t_s
  672.        manpage.
  673.  
  674.        Then you'll need to know how to manipulate the Perl stack.
  675.        That's described in the _p_e_r_l_c_a_l_l manpage.
  676.  
  677.        Once you've understood those, embedding Perl in C is easy.
  678.  
  679.        Since C has no built-in function for integer
  680.        exponentiation, let's make Perl's ** operator available to
  681.        it (this is less useful than it sounds, since Perl
  682.        implements ** with C's _p_o_w_(_) function).  First I'll create
  683.        a stub exponentiation function in _p_o_w_e_r_._p_l:
  684.  
  685.            ssssuuuubbbb eeeexxxxppppoooo {{{{
  686.                mmmmyyyy (((($$$$aaaa,,,, $$$$bbbb)))) ==== @@@@____;;;;
  687.                rrrreeeettttuuuurrrrnnnn $$$$aaaa ******** $$$$bbbb;;;;
  688.            }}}}
  689.  
  690.        Now I'll create a C program, _p_o_w_e_r_._c, with a function
  691.        _P_e_r_l_P_o_w_e_r_(_) that contains all the perlguts necessary to
  692.        push the two arguments into _e_x_p_o_(_) and to pop the return
  693.        value out.  Take a deep breath...
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724. 30/Jan/96                perl 5.002 with                       11
  725.  
  726.  
  727.  
  728.  
  729.  
  730. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  731.  
  732.  
  733.            ####iiiinnnncccclllluuuuddddeeee <<<<ssssttttddddiiiioooo....hhhh>>>>
  734.            ####iiiinnnncccclllluuuuddddeeee <<<<EEEEXXXXTTTTEEEERRRRNNNN....hhhh>>>>
  735.            ####iiiinnnncccclllluuuuddddeeee <<<<ppppeeeerrrrllll....hhhh>>>>
  736.  
  737.            ssssttttaaaattttiiiicccc PPPPeeeerrrrllllIIIInnnntttteeeerrrrpppprrrreeeetttteeeerrrr ****mmmmyyyy____ppppeeeerrrrllll;;;;
  738.  
  739.            ssssttttaaaattttiiiicccc vvvvooooiiiidddd
  740.            PPPPeeeerrrrllllPPPPoooowwwweeeerrrr((((iiiinnnntttt aaaa,,,, iiiinnnntttt bbbb))))
  741.            {{{{
  742.              ddddSSSSPPPP;;;;                            ////**** iiiinnnniiiittttiiiiaaaalllliiiizzzzeeee ssssttttaaaacccckkkk ppppooooiiiinnnntttteeeerrrr      ****////
  743.              EEEENNNNTTTTEEEERRRR;;;;                          ////**** eeeevvvveeeerrrryyyytttthhhhiiiinnnngggg ccccrrrreeeeaaaatttteeeedddd aaaafffftttteeeerrrr hhhheeeerrrreeee ****////
  744.              SSSSAAAAVVVVEEEETTTTMMMMPPPPSSSS;;;;                       ////**** ............iiiissss aaaa tttteeeemmmmppppoooorrrraaaarrrryyyy vvvvaaaarrrriiiiaaaabbbblllleeee....   ****////
  745.              PPPPUUUUSSSSHHHHMMMMAAAARRRRKKKK((((sssspppp))));;;;                   ////**** rrrreeeemmmmeeeemmmmbbbbeeeerrrr tttthhhheeee ssssttttaaaacccckkkk ppppooooiiiinnnntttteeeerrrr    ****////
  746.              XXXXPPPPUUUUSSSSHHHHssss((((ssssvvvv____2222mmmmoooorrrrttttaaaallll((((nnnneeeewwwwSSSSVVVViiiivvvv((((aaaa))))))))))));;;; ////**** ppppuuuusssshhhh tttthhhheeee bbbbaaaasssseeee oooonnnnttttoooo tttthhhheeee ssssttttaaaacccckkkk  ****////
  747.              XXXXPPPPUUUUSSSSHHHHssss((((ssssvvvv____2222mmmmoooorrrrttttaaaallll((((nnnneeeewwwwSSSSVVVViiiivvvv((((bbbb))))))))))));;;; ////**** ppppuuuusssshhhh tttthhhheeee eeeexxxxppppoooonnnneeeennnntttt oooonnnnttttoooo ssssttttaaaacccckkkk  ****////
  748.              PPPPUUUUTTTTBBBBAAAACCCCKKKK;;;;                      ////**** mmmmaaaakkkkeeee llllooooccccaaaallll ssssttttaaaacccckkkk ppppooooiiiinnnntttteeeerrrr gggglllloooobbbbaaaallll ****////
  749.              ppppeeeerrrrllll____ccccaaaallllllll____ppppvvvv((((""""eeeexxxxppppoooo"""",,,, GGGG____SSSSCCCCAAAALLLLAAAARRRR))));;;; ////**** ccccaaaallllllll tttthhhheeee ffffuuuunnnnccccttttiiiioooonnnn             ****////
  750.              SSSSPPPPAAAAGGGGAAAAIIIINNNN;;;;                        ////**** rrrreeeeffffrrrreeeesssshhhh ssssttttaaaacccckkkk ppppooooiiiinnnntttteeeerrrr         ****////
  751.                                            ////**** ppppoooopppp tttthhhheeee rrrreeeettttuuuurrrrnnnn vvvvaaaalllluuuueeee ffffrrrroooommmm ssssttttaaaacccckkkk ****////
  752.              pppprrrriiiinnnnttttffff ((((""""%%%%dddd ttttoooo tttthhhheeee %%%%ddddtttthhhh ppppoooowwwweeeerrrr iiiissss %%%%dddd....\\\\nnnn"""",,,, aaaa,,,, bbbb,,,, PPPPOOOOPPPPiiii))));;;;
  753.              PPPPUUUUTTTTBBBBAAAACCCCKKKK;;;;
  754.              FFFFRRRREEEEEEEETTTTMMMMPPPPSSSS;;;;                       ////**** ffffrrrreeeeeeee tttthhhhaaaatttt rrrreeeettttuuuurrrrnnnn vvvvaaaalllluuuueeee        ****////
  755.              LLLLEEEEAAAAVVVVEEEE;;;;                       ////**** ............aaaannnndddd tttthhhheeee XXXXPPPPUUUUSSSSHHHHeeeedddd """"mmmmoooorrrrttttaaaallll"""" aaaarrrrggggssss....****////
  756.            }}}}
  757.  
  758.            iiiinnnntttt mmmmaaaaiiiinnnn ((((iiiinnnntttt aaaarrrrggggcccc,,,, cccchhhhaaaarrrr ********aaaarrrrggggvvvv,,,, cccchhhhaaaarrrr ********eeeennnnvvvv))))
  759.            {{{{
  760.              cccchhhhaaaarrrr ****mmmmyyyy____aaaarrrrggggvvvv[[[[2222]]]];;;;
  761.  
  762.              mmmmyyyy____ppppeeeerrrrllll ==== ppppeeeerrrrllll____aaaalllllllloooocccc(((())));;;;
  763.              ppppeeeerrrrllll____ccccoooonnnnssssttttrrrruuuucccctttt(((( mmmmyyyy____ppppeeeerrrrllll ))));;;;
  764.  
  765.              mmmmyyyy____aaaarrrrggggvvvv[[[[1111]]]] ==== ((((cccchhhhaaaarrrr ****)))) mmmmaaaalllllllloooocccc((((11110000))));;;;
  766.              sssspppprrrriiiinnnnttttffff((((mmmmyyyy____aaaarrrrggggvvvv[[[[1111]]]],,,, """"ppppoooowwwweeeerrrr....ppppllll""""))));;;;
  767.  
  768.              ppppeeeerrrrllll____ppppaaaarrrrsssseeee((((mmmmyyyy____ppppeeeerrrrllll,,,, NNNNUUUULLLLLLLL,,,, aaaarrrrggggcccc,,,, mmmmyyyy____aaaarrrrggggvvvv,,,, eeeennnnvvvv))));;;;
  769.  
  770.              PPPPeeeerrrrllllPPPPoooowwwweeeerrrr((((3333,,,, 4444))));;;;                      ////************ CCCCoooommmmppppuuuutttteeee 3333 ******** 4444 ************////
  771.  
  772.              ppppeeeerrrrllll____ddddeeeessssttttrrrruuuucccctttt((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  773.              ppppeeeerrrrllll____ffffrrrreeeeeeee((((mmmmyyyy____ppppeeeerrrrllll))));;;;
  774.            }}}}
  775.  
  776.  
  777.        Compile and run:
  778.  
  779.            %%%% cccccccc ----oooo ppppoooowwwweeeerrrr ppppoooowwwweeeerrrr....cccc ----LLLL////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE
  780.            ----IIII////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////ppppeeeerrrrllll5555////aaaallllpppphhhhaaaa----ddddeeeecccc____oooossssffff////CCCCOOOORRRREEEE ----llllppppeeeerrrrllll ----llllmmmm
  781.  
  782.            %%%% ppppoooowwwweeeerrrr
  783.            3333 ttttoooo tttthhhheeee 4444tttthhhh ppppoooowwwweeeerrrr iiiissss 88881111....
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790. 30/Jan/96                perl 5.002 with                       12
  791.  
  792.  
  793.  
  794.  
  795.  
  796. PERLEMBED(1)   User Contributed Perl Documentation   PERLEMBED(1)
  797.  
  798.  
  799. MMMMOOOORRRRAAAALLLL
  800.        You can sometimes _w_r_i_t_e _f_a_s_t_e_r _c_o_d_e in C, but you can
  801.        always _w_r_i_t_e _c_o_d_e _f_a_s_t_e_r in Perl.  Since you can use each
  802.        from the other, combine them as you wish.
  803.  
  804. AAAAUUUUTTTTHHHHOOOORRRR
  805.        Jon Orwant _<_o_r_w_a_n_t_@_m_e_d_i_a_._m_i_t_._e_d_u_>, with contributions from
  806.        Tim Bunce, Tom Christiansen, Dov Grobgeld, and Ilya
  807.        Zakharevich.
  808.  
  809.        December 18, 1995
  810.  
  811.        Some of this material is excerpted from my book: _P_e_r_l _5
  812.        _I_n_t_e_r_a_c_t_i_v_e, Waite Group Press, 1996 (ISBN 1-57169-064-6)
  813.        and appears courtesy of Waite Group Press.
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856. 30/Jan/96                perl 5.002 with                       13
  857.  
  858.  
  859.