1##
2##        ____           _
3##    ___|  _ \ ___ _ __| |
4##   / _ \ |_) / _ \ '__| |
5##  |  __/  __/  __/ |  | |
6##   \___|_|   \___|_|  |_|
7##
8##  ePerl -- Embedded Perl 5 Language
9##
10##  ePerl interprets an ASCII file bristled with Perl 5 program
11##  statements by evaluating the Perl 5 code while passing through
12##  the plain ASCII data. It can operate in various ways: As a
13##  stand-alone Unix filter or integrated Perl 5 module for general
14##  file generation tasks and as a powerful Webserver scripting
15##  language for dynamic HTML page programming.
16##
17##  ======================================================================
18##
19##  Copyright (c) 1996,1997 Ralf S. Engelschall, All rights reserved.
20##
21##  This program is free software; it may be redistributed and/or modified
22##  only under the terms of either the Artistic License or the GNU General
23##  Public License, which may be found in the ePerl source distribution.
24##  Look at the files ARTISTIC and COPYING or run ``eperl -l'' to receive
25##  a built-in copy of both license files.
26##
27##  This program is distributed in the hope that it will be useful, but
28##  WITHOUT ANY WARRANTY; without even the implied warranty of
29##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either the
30##  Artistic License or the GNU General Public License for more details.
31##
32##  ======================================================================
33##
34##  eperl.pod -- ePerl Documentation in Plain Old Document (POD) Format
35##
36
37=head1 NAME
38
39ePerl - Embedded Perl 5 Language
40
41=head1 VERSION
42
43@V@
44
45=head1 SYNOPSIS
46
47B<eperl>
48[B<-d> I<name>=I<value>]
49[B<-D> I<name>=I<value>]
50[B<-B> I<begin_delimiter>]
51[B<-E> I<end_delimiter>]
52[B<-i>]
53[B<-m> I<mode>]
54[B<-o> I<outputfile>]
55[B<-k>]
56[B<-I> I<directory>]
57[B<-P>]
58[B<-C>]
59[B<-L>]
60[B<-x>]
61[B<-T>]
62[B<-w>]
63[B<-c>]
64[I<inputfile>]
65
66B<eperl>
67[B<-r>]
68[B<-l>]
69[B<-v>]
70[B<-V>]
71
72=head1 DESCRIPTION
73
74=head2 Abstract
75
76ePerl interprets an ASCII file bristled with Perl 5 program statements by
77evaluating the Perl 5 code while passing through the plain ASCII data. It can
78operate in various ways: As a stand-alone Unix filter or integrated Perl 5
79module for general file generation tasks and as a powerful Webserver scripting
80language for dynamic HTML page programming.
81
82=head2 Introduction
83
84The B<eperl> program is the I<Embedded Perl 5 Language> interpreter. This
85really is a full-featured Perl 5 interpreter, but with a different calling
86environment and source file layout than the default Perl interpreter (usually
87the executable B<perl> or B<perl5> on most systems).  It is designed for
88general ASCII file generation with the philosophy of I<embedding> the Perl 5
89program code into the ASCII data instead of the usual way where you embed the
90ASCII data into a Perl 5 program (usually by quoting the data and using them
91via C<print> statements).  So, instead of writing a plain Perl script like
92
93  #!/path/to/perl
94  print "foo bar\n";
95  print "baz quux\n";
96  for ($i = 0; $i < 10; $i++) { print "foo #${i}\n"; }
97  print "foo bar\n";
98  print "baz quux\n";
99
100you can write it now as an ePerl script:
101
102  #!/path/to/eperl
103  foo bar
104  baz quux
105  <: for ($i = 0; $i < 10; $i++) { print "foo #${i}\n"; } :>
106  foo bar
107  baz quux
108
109Although the ePerl variant has a different source file layout, the semantic is
110the same, i.e. both scripts create exactly the same resulting data on
111C<STDOUT>.
112
113=head2 Intention
114
115ePerl is simply a glue code which combines the programming power of the Perl 5
116interpreter library with a tricky embedding technique.  The embedding trick is
117this: it converts the source file into a valid Perl script which then gets
118I<entirely> evaluated by only one internal instance of the Perl 5 interpreter.
119To achieve this, ePerl translates all plain code into (escaped) Perl 5 strings
120placed into F<print> constructs while passing through all embedded native Perl
1215 code. As you can see, ePerl itself does exactly the same internally, a silly
122programmer had to do when writing a plain Perl generation script.
123
124Due to the nature of such bristled code, ePerl is really the better attempt
125when the generated ASCII data contains really more static as dynamic data. Or
126in other words: I<Use ePerl if you want to keep the most of the generated ASCII
127data in plain format while just programming some bristled stuff.> Do not use it
128when generating pure dynamic data. There it brings no advantage to the
129ordinary program code of a plain Perl script. So, the static part should be at
130least 60% or the advantage becomes a disadvantage.
131
132ePerl in its origin was actually designed for an extreme situation: as a
133webserver scripting-language for on-the-fly HTML page generation. Here you
134have the typical case that usually 90% of the data consists of pure static
135HTML tags and plain ASCII while just the remaining 10% are programming
136constructs which dynamically generate more markup code. This is the reason why
137ePerl beside its standard Unix filtering runtime-mode also supports the
138CGI/1.1 and NPH-CGI/1.1 interfaces.
139
140=head2 Embedded Perl Syntax
141
142Practically you can put any valid Perl constructs inside the ePerl blocks the
143used Perl 5 interpreter library can evaluate. But there are some important
144points you should always remember and never forget when using ePerl:
145
146=over 4
147
148=item I<1. Delimiters are always discarded.>
149
150Trivially to say, but should be mentioned at least once. The ePerl block
151delimiters are always discarded and are only necessary for ePerl to recognize
152the embedded Perl constructs. They are never passed to the final output.
153
154=item I<2. Generated content has to go to C<STDOUT>.>
155
156Although you can define subroutines, calculate some data, etc.  inside ePerl
157blocks only data which is explicitly written to the C<STDOUT> filehandle is
158expanded. In other words: When an ePerl block does not generate content on
159C<STDOUT>, it is entirely replaced by an empty string in the final output.
160But when content is generated it is put at the point of the ePerl block in the
161final output. Usually contents is generated via pure C<print> constructs which
162implicitly use C<STDOUT> when no filehandle is given.
163
164=item I<3. Generated content on C<STDERR> always leads to an error.>
165
166Whenever content is generated on the C<STDERR> filehandle, ePerl displays an
167error (including the STDERR content). Use this to exit on errors while passing
168errors from ePerl blocks to the calling environment.
169
170=item I<4. Last semicolon.>
171
172Because of the following point 6 (see below) and the fact that most of the
173users don't have the internal ePerl block translations in mind, ePerl is smart
174about the last semicolon. Usually every ePerl block has to end with the
175semicolon of the last command.
176
177   <: cmd; ...; cmd; :>
178
179But when the last semicolon is missing it is automatically added
180by ePerl, i.e.
181
182   <: cmd; ...; cmd :>
183
184is also correct syntax.  But sometimes it is necessary to force ePerl I<not>
185to add the semicolon. Then you can add a ``C<_>'' (underscore) as the last
186non-whitespace character in the block to force ePerl to leave the final
187semicolon. Use this for constructs like the following
188
189   <: if (...) { _:>
190   foo
191   <: } else { _:>
192   bar
193   <: } :>
194
195where you want to spread a Perl directive over more ePerl blocks.
196
197=item I<5. Shorthand for C<print>-only blocks.>
198
199Because most of the time ePerl is used just to interpolate variables, e.g.
200
201   <: print $VARIABLE; :>
202
203it is useful to provide a shortcut for this kind of constructs.  So ePerl
204provides a shortcut via the character '='. When it immediately (no whitespaces
205allowed here) follows the begin delimiter of an ePerl block a C<print>
206statement is implicitly generated, i.e. the above block is equivalent to
207
208   <:=$VARIABLE:>
209
210Notice that the semicolon was also removed here, because it gets automatically
211added (see above).
212
213=item I<6. Special EndOfLine discard command for ePerl blocks.>
214
215ePerl provides a special discard command named ``C<//>'' which discards all
216data up-to and including the following newline character when directly
217followed an end block delimiter. Usually when you write
218
219  foo
220  <: $x = 1; :>
221  quux
222
223the result is
224
225  foo
226
227  quux
228
229because ePerl always preserves code around ePerl blocks, even
230just newlines. But when you write
231
232  foo
233  <: $x = 1; :>//
234  quux
235
236the result is
237
238  foo
239  quux
240
241because the ``C<//>'' deleted all stuff to the end of the line, I<including>
242the newline.
243
244=item I<7. Restrictions in parsing.>
245
246Every program has its restrictions, ePerl too. Its handicap is that Perl is
247not only a rich language, it is a horrible one according to parsing its
248constructs. Perhaps you know the phrase ,,Only F<perl> can parse I<Perl>''.
249Think about it. The implication of this is that ePerl never tries to parse the
250ePerl blocks itself. It entirely relies on the Perl interpreter library,
251because it is the only instance which can do this without errors.  But the
252problem is that ePerl at least has to recognize the begin and end positions of
253those ePerl blocks.
254
255There are two ways: It can either look for the end delimiter while parsing but
256at least recognize quoted strings (where the end delimiter gets treated as
257pure data). Or it can just move forward to the next end delimiter and say that
258it have not occur inside Perl constructs. In ePerl 2.0 the second one was
259used, while in ePerl 2.1 the first one was taken because a lot of users wanted
260it this way while using bad end delimiters like ``C<E<gt>>''. But actually the
261author has again revised its opinion and decided to finally use the second
262approach which is used since ePerl 2.2 now. Because while the first one allows
263more trivial delimiters (which itself is not a really good idea), it fails
264when constructs like ``C<m|"[^"]+"|>'' etc.  are used inside ePerl blocks. And
265it is easier to escape end delimiters inside Perl constructs (for instance via
266backslashes in quoted strings) than rewrite complex Perl constructs to use
267even number of quotes.
268
269So, whenever your end delimiter also occurs inside Perl constructs you have to
270escape it in any way.
271
272=item I<8. HTML entity conversion.>
273
274Because one of ePerl's usage is as a server-side scripting-language for HTML
275pages, there is a common problem in conjunction with HTML editors.  They
276cannot know ePerl blocks, so when you enter those blocks inside the editors
277they usually encode some characters with the corresponding HTML entities. The
278problem is that this encoding leads to invalid Perl code. ePerl provides the
279option B<-C> for decoding these entities which is automatically turned on in
280CGI modes. See description below under option B<-C> for more details.
281
282=back
283
284=head2 Runtime Modes
285
286ePerl can operate in three different runtime modes:
287
288=over 4
289
290=item I<Stand-alone Unix filter mode>
291
292This is the default operation mode when used as a generation tool from the
293Unix shell or as a batch-processing tool from within other programs or
294scripts:
295
296  $ eperl [options] - < inputfile > outputfile
297  $ eperl [options] inputfile > outputfile
298  $ eperl [options] -o outputfile - < inputfile
299  $ eperl [options] -o outputfile inputfile
300
301As you can see, ePerl can be used in any combination of STDIO and external
302files. Additionally there are two interesting variants of using this mode.
303First you can use ePerl in conjunction with the Unix I<Shebang> magic
304technique to implicitly select it as the interpreter for your script similar
305to the way you are used to with the plain Perl interpreter:
306
307  #!/path/to/eperl [options]
308  foo
309  <: print "bar"; :>
310  quux
311
312Second, you can use ePerl in conjunction with the Bourne-Shell I<Here
313Document> technique from within you shell scripts:
314
315  #!/bin/sh
316  ...
317  eperl [options] - <<EOS
318  foo
319  <: print "quux"; :>
320  quux
321  EOS
322  ...
323
324And finally you can use ePerl directly from within Perl programs by the use of
325the Parse::ePerl(3) package (assuming that you have installed this also; see
326file F<INSTALL> inside the ePerl distribution for more details):
327
328  #!/path/to/perl
329  ...
330  use Parse::ePerl;
331  ...
332  $script = <<EOT;
333  foo
334  <: print "quux"; :>
335  quux
336  EOT
337  ...
338  $result = Parse::ePerl::Expand({
339      Script => $script,
340      Result => \$result,
341  });
342  ...
343  print $result;
344  ...
345
346See Parse::ePerl(3) for more details.
347
348=item I<CGI/1.1 compliant interface mode>
349
350This is the runtime mode where ePerl uses the CGI/1.1 interface of a webserver
351when used as a I<Server-Side Scripting Language> on the Web. ePerl enters this
352mode automatically when the CGI/1.1 environment variable C<PATH_TRANSLATED> is
353set and its or the scripts filename does I<not> begin with the NPH prefix
354``F<nph->''.  In this runtime mode it prefixes the resulting data with
355HTTP/1.0 (default) or HTTP/1.1 (if identified by the webserver) compliant
356response header lines.
357
358ePerl also recognizes HTTP header lines at the beginning of the scripts
359generated data, i.e. for instance you can generate your own HTTP headers like
360
361   <? $url = "..";
362      print "Location: $url\n";
363      print "URI: $url\n\n"; !>
364   <html>
365   ...
366
367But notice that while you can output arbitrary headers, most webservers
368restrict the headers which are accepted via the CGI/1.1 interface. Usually you
369can provide only a few specific HTTP headers like C<Location> or C<Status>.
370If you need more control you have to use the NPH-CGI/1.1 interface mode.
371
372Additionally ePerl provides a useful feature in this mode: It can switch its
373UID/GID to the owner of the script if it runs as a Unix I<SetUID> program (see
374below under L<Security> and the option ``u+s'' of chmod(1)).
375
376There are two commonly known ways of using this CGI/1.1 interface mode on the
377Web. First, you can use it to explicitly transform plain HTML files into
378CGI/1.1 scripts via the I<Shebang> technique (see above). For an Apache
379webserver just put the following line as the first line of the file:
380
381  #!/path/to/eperl -mc
382
383Then rename the script from F<file.html> to F<file.cgi> and set its execution
384bit via
385
386  $ mv file.html file.cgi
387  $ chmod a+rx file.cgi
388
389Now make sure that Apache accepts F<file.cgi> as a CGI program by enabling CGI
390support for the directory where F<file.cgi> resides. For this add the line
391
392  Options +ExecCGI
393
394to the F<.htaccess> file in this directory. Finally make sure that Apache
395really recognizes the extension F<.cgi>. Perhaps you additionally have to add
396the following line to your F<httpd.conf> file:
397
398  AddHandler cgi-script .cgi
399
400Now you can use F<file.cgi> instead of F<file.html> and make advantage of the
401achieved programming capability by bristling F<file.cgi> with your Perl
402blocks (or the transformation into a CGI script would be useless).
403
404Alternatively (or even additionally) a webmaster can enable ePerl support in a
405more seemless way by configuring ePerl as a real implicit server-side
406scripting language. This is done by assigning a MIME-type to the various valid
407ePerl file extensions and forcing all files with this MIME-type to be
408internally processed via the ePerl interpreter. You can accomplish this for
409Apache by adding the following to your F<httpd.conf> file
410
411  AddType      application/x-httpd-eperl  .phtml .eperl .epl
412  Action       application/x-httpd-eperl  /internal/cgi/eperl
413  ScriptAlias  /internal/cgi              /path/to/apache/cgi-bin
414
415and creating a copy of the F<eperl> program in your CGI-directory:
416
417  $ cp -p /path/to/eperl /path/to/apache/cgi-bin/eperl
418
419Now all files with the extensions F<.phtml>, F<.eperl> and F<.epl> are
420automatically processed by the ePerl interpreter. There is no need for a
421I<Shebang> line or any locally enabled CGI mode.
422
423One final hint: When you want to test your scripts offline, just run them with
424forced CGI/1.1 mode from your shell. But make sure you prepare all environment
425variables your script depends on, e.g. C<QUERY_STRING> or C<PATH_INFO>.
426
427  $ export QUERY_STRING="key1=value1&key2=value2"
428  $ eperl -mc file.phtml
429
430
431=item I<NPH-CGI/1.1 compliant interface mode>
432
433This runtime mode is a special variant of the CGI/1.1 interface mode, because
434most webservers (e.g. Apache) provide it for special purposes.   It is known
435as I<Non-Parsed-Header> (NPH) CGI/1.1 mode and is usually used by the
436webserver when the filename of the CGI program is prefixed with ``C<nph->''.
437In this mode the webserver does no processing on the HTTP response headers and
438no buffering of the resulting data, i.e. the CGI program actually has to
439provide a complete HTTP response itself. The advantage is that the program can
440generate arbitrary HTTP headers or MIME-encoded multi-block messages.
441
442So,
443above we have renamed the file to F<file.cgi> which restricted us a little
444bit. When we alternatively rename F<file.html> to F<nph-file.cgi> and force
445the NPH-CGI/1.1 interface mode via option B<-mn> then this file becomes a
446NPH-CGI/1.1 compliant program under Apache and other webservers. Now our
447script can provide its own HTTP response (it need not, because when absent
448ePerl provides a default one for it).
449
450  #!/path/to/bin/eperl -mn
451  <? print "HTTP/1.0 200 Ok\n";
452     print "X-MyHeader: Foo Bar Quux\n";
453     print "Content-type: text/html\n\n";
454  <html>
455  ...
456
457As you expect this can be also used with the implicit Server-Side Scripting
458Language technique. Put
459
460  AddType      application/x-httpd-eperl  .phtml .eperl .epl
461  Action       application/x-httpd-eperl  /internal/cgi/nph-eperl
462  ScriptAlias  /internal/cgi              /path/to/apache/cgi-bin
463
464into your F<httpd.conf> and run the command
465
466  $ cp -p /path/to/eperl /path/to/apache/cgi-bin/nph-eperl
467
468from your shell. I<This is the preferred way of using ePerl as a Server-Side
469Scripting Language, because it provides most flexibility>.
470
471=back
472
473=head2 Security
474
475When you are installing ePerl as a CGI/1.1 or NPH-CGI/1.1 compliant program
476(see above for detailed description of these modes) via
477
478  $ cp -p /path/to/eperl /path/to/apache/cgi-bin/eperl
479  $ chown root /path/to/apache/cgi-bin/eperl
480  $ chmod u+s  /path/to/apache/cgi-bin/eperl
481
482or
483
484  $ cp -p /path/to/eperl /path/to/apache/cgi-bin/nph-eperl
485  $ chown root /path/to/apache/cgi-bin/nph-eperl
486  $ chmod u+s  /path/to/apache/cgi-bin/nph-eperl
487
488i.e. with I<SetUID> bit enabled for the B<root> user, ePerl can switch to the
489UID/GID of the I<scripts owner>. Although this is a very useful feature for
490script programmers (because one no longer need to make auxiliary files
491world-readable and temporary files world-writable!), it can be to risky for
492you when you are paranoid about security of SetUID programs. If so just don't
493install ePerl with enabled SetUID bit! This is the reason why ePerl is per
494default only installed as a Stand-Alone Unix filter which never needs this
495feature.
496
497For those of us who decided that this feature is essential for them ePerl
498tries really hard to make it secure. The following steps have to be
499successfully passed before ePerl actually switches its UID/GID (in this
500order):
501
502  1. The script has to match the following extensions:
503     .html, .phtml, .ephtml, .epl, .pl, .cgi
504  2. The UID of the calling process has to be a valid UID,
505     i.e. it has to be found in the systems password file
506  3. The UID of the calling process has to match the
507     following users: root, nobody
508  4. The UID of the script owner has to be a valid UID,
509     i.e. it has to be found in the systems password file
510  5. The GID of the script group has to be a valid GID,
511     i.e. it has to be found in the systems group file
512  6. The script has to stay below or in the owners homedir
513
514I<IF ONLY ONE OF THOSE STEPS FAIL, NO UID/GID SWITCHING TAKES PLACE!>.
515Additionally (if C<DO_ON_FAILED_STEP> was defined as C<STOP_AND_ERROR> in
516F<eperl_security.h> - not per default defined this way!) ePerl can totally stop
517processing and display its error page.  This is for the really paranoid
518webmasters. Per default when any step failed the UID/GID switching is just
519disabled, but ePerl goes on with processing. Alternatively you can disable
520some steps at compile time. See F<eperl_security.h>.
521
522I<Also remember that ePerl always eliminates the effective UID/GID,
523independent of the runtime mode and independent if ePerl has switched to the
524UID/GID of the owner. For security reasons, the effective UID/GID is always
525destroyed before the script is executed.>
526
527=head2 ePerl Preprocessor
528
529ePerl provides an own preprocessor similar to F<CPP> in style which is either
530enabled manually via option B<-P> or automatically when ePerl runs in
531(NPH-)CGI mode.  The following directives are supported:
532
533=over 4
534
535=item C<#include path>
536
537This directive is an include directive which can be used to include really any
538stuff, but was actually designed to be used to include other ePerl source
539files. The I<path> can be either a relative or absolute path for the local
540filesystem or a fully qualified HTTP URL.
541
542In case of the absolute path the file is directly accessed on the filesystem,
543while the relative path is first searched in the current working directory and
544then in all directories specified via option B<-I>. In the third case
545(HTTP URL) the file is retrieves via a HTTP/1.0 request on the network.
546Here HTTP redirects (response codes 301 and 302) are supported, too.
547
548Notice: While ePerl strictly preserves the line numbers when translating the
549bristled ePerl format to plain Perl format, the ePerl preprocessor can't do
550this (because its a B<pre>processor which expands) for this directive.  So,
551whenever you use C<#include>, remember that line numbers in error messages are
552wrong.
553
554Also notice one important security aspect: Because you can include any stuff
555as it is provided with this directive, use it only for stuff which is under
556your direct control. Don't use this directive to include foreign data, at
557least not from external webservers. For instance say you have a ePerl page
558with C<#include http://www.foreigner.com/nice-page.html> and at the next
559request of this page your filesystem is lost! Why? Because the foreigner
560recognizes that you include his page and are using ePerl and just put a simple
561``C<E<lt>?  system("rm -rf /"); !E<gt>>'' in his page. Think about it.
562I<NEVER USE #INCLUDE FOR ANY DATA WHICH IS NOT UNDER YOUR OWN CONTROL>.
563Instead always use C<#sinclude> for such situations.
564
565=item C<#sinclude path>
566
567This is the secure variant of C<#include> where after reading the data from
568I<path> all ePerl begin and end delimiters are removed. So risky ePerl blocks
569lost their meaning and are converted to plain text. Always use this directive
570when you want to include data which is not under your own control.
571
572=item C<#if expr>, C<#elsif expr>, C<#else>, C<#endif>
573
574These implement a CPP-style C<#if-[#else-]#endif> construct, but with a Perl
575semantic. While the other directives are real preprocessor commands which are
576evaluated at the preprocessing step, this construct is actually just
577transformed into a low-level ePerl construct, so it is B<not> actually
578evaluated at the preprocessing step. It is just a handy shortcut for the
579following (where BD is the currently used begin delimiter and ED the end
580delimiter):
581
582  ``#if expr''    ->  ``BD if (expr) { _ ED//''
583  ``#elsif expr'' ->  ``BD } elsif (expr) { _ ED//''
584  ``#else''       ->  ``BD } else { _ ED//''
585  ``#endif''      ->  ``BD } _ ED//''
586
587The advantage of this unusual aproach is that the if-condition really can be
588any valid Perl expression which provides maximum flexibility. The disadvantage
589is that you cannot use the if-construct to make real preprocessing decisions.
590As you can see, the design goal was just to provide a shorthand for the more
591complicated Perl constructs.
592
593=item C<#c>
594
595This is the comment directive which just discards all data up to and including
596the newline character. Use this one to comment out any stuff, even other
597preprocessor directives.
598
599=back
600
601=head2 Provided Functionality
602
603Up to know you've understand that ePerl provides a nice facility to embed Perl
604code into any ASCII data. But now the typical question is: Which Perl code can
605be put into these ePerl blocks and does ePerl provide any special
606functionality inside these ePerl blocks?
607
608The answers are: First, you can put really I<any> Perl code into the ePerl
609blocks which are valid to the Perl interpreter ePerl was linked with. Second,
610ePerl does I<not> provide any special functionality inside these ePerl blocks,
611because Perl is already sophisticated enough ;-)
612
613The implication of this is: Because you can use any valid Perl code you can
614make use of all available Perl 5 modules, even those ones which use shared
615objects (because ePerl I<is> a Perl interpreter, including DynaLoader
616support). So, browse to the Comprehensive Perl Archive Network (CPAN) via
617http://www.perl.com/perl/CPAN and grab your favorite packages which can make
618your life easier (both from within plain Perl scripts I<and> ePerl scripts)
619and just use the construct ``C<use name;>'' in any ePerl block to use them
620from within ePerl.
621
622When using ePerl as a Server-Side-Scripting-Language I really recommend you to
623install at least the packages F<CGI.pm> (currently vers.  2.36),
624F<HTML-Stream> (1.40), F<libnet> (1.0505) and F<libwww-perl> (5.08).  When you
625want to generate on-the-fly images as well, I recommend you to additionally
626install at least F<GD> (1.14) and F<Image-Size> (2.3). The ePerl interpreter
627in conjunction with these really sophisticated Perl 5 modules will provide you
628with maximum flexibility and functionality. In other words: I<Make use of
629maximum Software Leverage in the hackers world of Perl as great as possible>.
630
631=head1 OPTIONS
632
633=over 4
634
635=item B<-d> I<name>=I<value>
636
637Sets a Perl variable in the package C<main> which can be referenced
638via C<$name> or more explicitly via C<$main::name>. The command
639
640  eperl -d name=value ..
641
642is actually equivalent to having
643
644  <? $name = value; !>
645
646at the beginning of I<inputfile>. This option can occur more than once.
647
648=item B<-D> I<name>=I<value>
649
650Sets a environment variable which can be referenced via C<$ENV{'variable'}>
651inside the Perl blocks. The command
652
653  eperl -D name=value ..
654
655is actually equivalent to
656
657  export name=value; eperl ...
658
659but the advantage of this option is that it doesn't manipulate the callers
660environment. This option can occur more than once.
661
662=item B<-B> I<begin_delimiter>
663
664Sets the Perl block begin delimiter string. Use this in conjunction with C<-E>
665to set different delimiters when using ePerl as an offline HTML
666creation-language while still using it as an online HTML scripting-language.
667Default delimiters are C<E<lt>?> and C<!E<gt>> for CGI modes and C<E<lt>:> and
668C<:E<gt>> for stand-alone Unix filtering mode.
669
670There are a lot of possible variations you could choose: "C<E<lt>:>" and
671"C<:E<gt>>" (the default ePerl stand-alone filtering mode delimiters),
672"C<E<lt>?>" and "C<!E<gt>>" (the default ePerl CGI interface mode delimiters),
673"C<E<lt>script language='ePerl'E<gt>>" and "C<E<lt>/scriptE<gt>>" (standard
674HTML scripting language style), "C<E<lt>script type="text/eperl"E<gt>>" and
675"C<E<lt>/scriptE<gt>>" (forthcoming HTML3.2+ aka Cougar style),
676"C<E<lt>eperlE<gt>>" and "C<E<lt>/eperlE<gt>>" (HTML-like style),
677"C<E<lt>!--#eperl code='>" and "C<' --E<gt>>" (NeoScript and SSI style) or
678even "C<E<lt>?>" and "C<E<gt>>" (PHP/FI style; but this no longer recommended
679because it can lead to parsing problems. Should be used only for backward
680compatibility to old ePerl versions 1.x).
681
682The begin and end delimiters are searched case-insensitive.
683
684=item B<-E> I<end_delimiter>
685
686Sets the Perl block end delimiter string. See also option B<-B>.
687
688=item B<-i>
689
690Forces the begin and end delimiters to be searched case-insensitive.  Use this
691when you are using delimiters like
692``C<E<lt>ePerlE<gt>>...C<E<lt>/ePerlE<gt>>'' or other more textual ones.
693
694=item B<-m> I<mode>
695
696This forces ePerl to act in a specific runtime mode.  See above for a detailed
697description of the three possible modes: Stand-alone filter (I<mode>=C<f>,
698i.e. option B<-mf>), CGI/1.1 interface mode (I<mode>=C<c>, i.e. option B<-mc>)
699or the NPH-CGI/1.1 interface mode (I<mode>=C<n>, i.e. option B<-mn>).
700
701=item B<-o> I<outputfile>
702
703Forces the output to be written to F<outputfile> instead of F<STDOUT>. Use
704this option when using ePerl as a filter. The outputfile ``F<->'' sets F<STDOUT>
705as the output handle explicitly. Notice that this file is relative to the
706source file directory when the runtime mode is forced to CGI or NPH-CGI.
707
708=item B<-k>
709
710Forces ePerl to keep the current working directory from where it was started.
711Per default ePerl will change to the directory where the file to be executed
712stays. This option is useful if you use ePerl as an offline filter on
713a temporary file.
714
715=item B<-x>
716
717This sets debug mode where ePerl outputs the internally created Perl script to
718the console (F</dev/tty>) before executing it. Only for debugging problems with
719the inputfile conversion.
720
721=item B<-I> I<directory>
722
723Specify a directory which is both used for C<#include> and C<#sinclude>
724directives of the ePerl preprocessor and added to C<@INC> under runtime.  This
725option can occur more than once.
726
727=item B<-P>
728
729Manually enables the special ePerl Preprocessor (see above). This option is
730enabled for all CGI modes automatically.
731
732=item B<-C>
733
734This enables the HTML entity conversion for ePerl blocks. This option is
735automatically forced in CGI modes.
736
737The solved problem here is the following: When you use ePerl as a
738Server-Side-Scripting-Language for HTML pages and you edit your ePerl source
739files via a HTML editor, the chance is high that your editor translates some
740entered characters to HTML entities, for instance ``C<E<lt>>'' to ``C<&lt;>''.
741This leads to invalid Perl code inside ePerl blocks, because the HTML editor
742has no knowledge about ePerl blocks. Using this option the ePerl parser
743automatically converts all entities found inside ePerl blocks back to plain
744characters, so the Perl interpreter again receives valid code blocks.
745
746=item B<-L>
747
748This enables the line continuation character ``C<\>'' (backslash) outside
749ePerl blocks. With this option you can spread oneline-data over more lines.
750But use with care: This option changes your data (outside ePerl blocks).
751Usually ePerl really pass through all surrounding data as raw data. With this
752option the newlines become new semantics.
753
754=item B<-T>
755
756This enabled Perl's I<Tainting mode> where the Perl interpreter takes special
757precautions called taint checks to prevent both obvious and subtle traps.  See
758perlsec(1) for more details.
759
760=item B<-w>
761
762This enables Warnings where the Perl interpreter produces some lovely
763diagnostics. See perldiag(1) for more details.
764
765=item B<-c>
766
767This runs a pure syntax check which is similar to ``C<perl -c>''.
768
769=item B<-r>
770
771This prints the internal ePerl README file to the console.
772
773=item B<-l>
774
775This prints the internal ePerl LICENSE file to the console.
776
777=item B<-v>
778
779This prints ePerl version information to the console.
780
781=item B<-V>
782
783Same as option B<-v> but additionally shows the Perl compilation parameters.
784
785=back
786
787=head1 ENVIRONMENT
788
789=head2 Used Variables
790
791=over 4
792
793=item C<PATH_TRANSLATED>
794
795This CGI/1.1 variable is used to determine the source file when ePerl operates
796as a NPH-CGI/1.1 program under the environment of a webserver.
797
798=back
799
800=head2 Provided Variables
801
802=over 4
803
804=item C<SCRIPT_SRC_PATH>
805
806The absolute pathname of the script. Use this when you want to
807directly access the script from within itself, for instance to do
808C<stat()> and other calls.
809
810=item C<SCRIPT_SRC_PATH_DIR>
811
812The directory part of C<SCRIPT_SRC_PATH>. Use this one when you want to
813directly access other files residing in the same directory as the script, for
814instance to read config files, etc.
815
816=item C<SCRIPT_SRC_PATH_FILE>
817
818The filename part of C<SCRIPT_SRC_PATH>. Use this one when you need the name
819of the script, for instance for relative self-references through URLs.
820
821=item C<SCRIPT_SRC_URL>
822
823The fully-qualified URL of the script. Use this when you need a URL for
824self-reference.
825
826=item C<SCRIPT_SRC_URL_DIR>
827
828The directory part of C<SCRIPT_SRC_URL>. Use this one when you want to
829directly access other files residing in the same directory as the script via
830the Web, for instance to reference images, etc.
831
832=item C<SCRIPT_SRC_URL_FILE>
833
834The filename part of C<SCRIPT_SRC_URL>. Use this one when you need the name of
835the script, for instance for relative self-references through URLs.  Actually
836the same as C<SCRIPT_SRC_PATH_FILE>, but provided for consistency.
837
838=item C<SCRIPT_SRC_SIZE>
839
840The filesize of the script, in bytes.
841
842=item C<SCRIPT_SRC_MODIFIED>
843
844The last modification time of the script, in seconds since 0 hours, 0 minutes,
8450 seconds, January 1, 1970, Coordinated Universal Time.
846
847=item C<SCRIPT_SRC_MODIFIED_CTIME>
848
849The last modification time of the script, in ctime(3) format (``WDAY MMM DD
850HH:MM:SS YYYY\n'').
851
852=item C<SCRIPT_SRC_MODIFIED_ISOTIME>
853
854The last modification time of the script, in ISO format (``DD-MM-YYYY
855HH:MM'').
856
857=item C<SCRIPT_SRC_OWNER>
858
859The username of the script owner.
860
861=item C<VERSION_INTERPRETER>
862
863The ePerl identification string.
864
865=item C<VERSION_LANGUAGE>
866
867The identification string of the used Perl interpreter library.
868
869=back
870
871=head2 Provided Built-In Images
872
873The following built-in images can be accessed via URL
874C</url/to/nph-eperl/>I<NAME>C<.gif>:
875
876=over 4
877
878=item C<logo.gif>
879
880The standard ePerl logo. Please do not include this one on your website.
881
882=item C<powered.gif>
883
884The ``I<powered by ePerl 2.2>'' logo. Feel free to use this on your website.
885
886=back
887
888=head1 AUTHOR
889
890  Ralf S. Engelschall
891  rse@engelschall.com
892  www.engelschall.com
893
894=head1 SEEALSO
895
896Parse::ePerl(3), Apache::ePerl(3).
897
898Web-References:
899
900  Perl:   perl(1),  http://www.perl.com/
901  ePerl:  eperl(1), http://www.engelschall.com/sw/eperl/
902  Apache: httpd(8), http://www.apache.org/
903
904=cut
905
906##EOF##
907