perl
view release on metacpan or search on metacpan
cpan/Pod-Simple/t/perlfaq.pod view on Meta::CPAN
packaging, and once you see the size of what it makes (well, unless
you use a shared I<libperl.so>), you'll probably want a complete
Perl install anyway.
=head2 How can I compile Perl into Java?
You can also integrate Java and Perl with the
Perl Resource Kit from O'Reilly and Associates. See
http://www.oreilly.com/catalog/prkunix/ .
Perl 5.6 comes with Java Perl Lingo, or JPL. JPL, still in
development, allows Perl code to be called from Java. See jpl/README
in the Perl source tree.
=head2 How can I get C<#!perl> to work on [MS-DOS,NT,...]?
For OS/2 just use
extproc perl -S -your_switches
as the first line in C<*.cmd> file (C<-S> due to a bug in cmd.exe's
`extproc' handling). For DOS one should first invent a corresponding
batch file and codify it in C<ALTERNATIVE_SHEBANG> (see the
F<INSTALL> file in the source distribution for more information).
The Win95/NT installation, when using the ActiveState port of Perl,
will modify the Registry to associate the C<.pl> extension with the
perl interpreter. If you install another port, perhaps even building
your own Win95/NT Perl from the standard sources by using a Windows port
of gcc (e.g., with cygwin or mingw32), then you'll have to modify
the Registry yourself. In addition to associating C<.pl> with the
interpreter, NT people can use: C<SET PATHEXT=%PATHEXT%;.PL> to let them
run the program C<install-linux.pl> merely by typing C<install-linux>.
Macintosh Perl programs will have the appropriate Creator and
Type, so that double-clicking them will invoke the Perl application.
I<IMPORTANT!>: Whatever you do, PLEASE don't get frustrated, and just
throw the perl interpreter into your cgi-bin directory, in order to
get your programs working for a web server. This is an EXTREMELY big
security risk. Take the time to figure out how to do it correctly.
=head2 Can I write useful Perl programs on the command line?
Yes. Read L<perlrun> for more information. Some examples follow.
(These assume standard Unix shell quoting rules.)
# sum first and last fields
perl -lane 'print $F[0] + $F[-1]' *
# identify text files
perl -le 'for(@ARGV) {print if -f && -T _}' *
# remove (most) comments from C program
perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c
# make file a month younger than today, defeating reaper daemons
perl -e '$X=24*60*60; utime(time(),time() + 30 * $X,@ARGV)' *
# find first unused uid
perl -le '$i++ while getpwuid($i); print $i'
# display reasonable manpath
echo $PATH | perl -nl -072 -e '
s![^/+]*$!man!&&-d&&!$s{$_}++&&push@m,$_;END{print"@m"}'
OK, the last one was actually an Obfuscated Perl Contest entry. :-)
=head2 Why don't Perl one-liners work on my DOS/Mac/VMS system?
The problem is usually that the command interpreters on those systems
have rather different ideas about quoting than the Unix shells under
which the one-liners were created. On some systems, you may have to
change single-quotes to double ones, which you must I<NOT> do on Unix
or Plan9 systems. You might also have to change a single % to a %%.
For example:
# Unix
perl -e 'print "Hello world\n"'
# DOS, etc.
perl -e "print \"Hello world\n\""
# Mac
print "Hello world\n"
(then Run "Myscript" or Shift-Command-R)
# VMS
perl -e "print ""Hello world\n"""
The problem is that none of these examples are reliable: they depend on the
command interpreter. Under Unix, the first two often work. Under DOS,
it's entirely possible that neither works. If 4DOS was the command shell,
you'd probably have better luck like this:
perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
Under the Mac, it depends which environment you are using. The MacPerl
shell, or MPW, is much like Unix shells in its support for several
quoting variants, except that it makes free use of the Mac's non-ASCII
characters as control characters.
Using qq(), q(), and qx(), instead of "double quotes", 'single
quotes', and `backticks`, may make one-liners easier to write.
There is no general solution to all of this. It is a mess, pure and
simple. Sucks to be away from Unix, huh? :-)
[Some of this answer was contributed by Kenneth Albanowski.]
=head2 Where can I learn about CGI or Web programming in Perl?
For modules, get the CGI or LWP modules from CPAN. For textbooks,
see the two especially dedicated to web stuff in the question on
books. For problems and questions related to the web, like ``Why
do I get 500 Errors'' or ``Why doesn't it run from the browser right
when it runs fine on the command line'', see these sources:
WWW Security FAQ
http://www.w3.org/Security/Faq/
( run in 1.415 second using v1.01-cache-2.11-cpan-98e64b0badf )