=head1 NAME
-perlfaq - frequently asked questions about Perl ($Date: 2003/01/03 20:00:25 $)
+perlfaq - frequently asked questions about Perl ($Date: 2003/01/26 17:45:46 $)
=head1 DESCRIPTION
=item *
-Why don't my <<HERE documents work?
+Why don't my E<lt>E<lt>HERE documents work?
=item *
=item *
-Why do I sometimes get an "Argument list too long" when I use <*>?
+Why do I sometimes get an "Argument list too long" when I use E<lt>*E<gt>?
=item *
=item *
-Why can't I just open(FH, ">file.lock")?
+Why can't I just open(FH, "E<gt>file.lock")?
=item *
=item *
-Why doesn't "my($foo) = <FILE>;" work right?
+Why doesn't "my($foo) = E<lt>FILEE<gt>;" work right?
=item *
=head1 NAME
-perlfaq2 - Obtaining and Learning about Perl ($Revision: 1.18 $, $Date: 2002/12/06 07:40:11 $)
+perlfaq2 - Obtaining and Learning about Perl ($Revision: 1.20 $, $Date: 2003/01/26 17:50:56 $)
=head1 DESCRIPTION
=head2 What are the Perl newsgroups on Usenet? Where do I post questions?
-The now defunct comp.lang.perl newsgroup has been superseded by the
-following groups:
+Several groups devoted to the Perl language are on Usenet:
comp.lang.perl.announce Moderated announcement group
- comp.lang.perl.misc Very busy group about Perl in general
- comp.lang.perl.moderated Moderated discussion group
+ comp.lang.perl.misc High traffic general Perl discussion
+ comp.lang.perl.moderated Moderated discussion group
comp.lang.perl.modules Use and development of Perl modules
comp.lang.perl.tk Using Tk (and X) from Perl
comp.infosystems.www.authoring.cgi Writing CGI scripts for the Web.
-There is also a Usenet gateway to Perl mailing lists sponsored by perl.org at
-nntp://nntp.perl.org , a web interface to the same lists at
-http://nntp.perl.org/group/ and these lists are also available under the
-C<perl.*> hierarchy at http://groups.google.com . Other groups are listed at
-http://lists.perl.org/ ( also known as http://lists.cpan.org/ ).
+Some years ago, comp.lang.perl was divided into those groups, and
+comp.lang.perl itself officially removed. While that group may still
+be found on some news servers, it is unwise to use it, because
+postings there will not appear on news servers which honour the
+official list of group names. Use comp.lang.perl.misc for topics
+which do not have a more-appropriate specific group.
-A nice place to ask questions is the PerlMonks site, http://www.perlmonks.org/
+There is also a Usenet gateway to Perl mailing lists sponsored by
+perl.org at nntp://nntp.perl.org , a web interface to the same lists
+at http://nntp.perl.org/group/ and these lists are also available
+under the C<perl.*> hierarchy at http://groups.google.com . Other
+groups are listed at http://lists.perl.org/ ( also known as
+http://lists.cpan.org/ ).
+
+A nice place to ask questions is the PerlMonks site,
+http://www.perlmonks.org/ , or the Perl Beginners mailing list
+http://lists.perl.org/showlist.cgi?name=beginners .
Note that none of the above are supposed to write your code for you:
asking questions about particular problems or general advice is fine,
by Tom Christiansen and Nathan Torkington,
with Foreword by Larry Wall
ISBN 1-56592-243-3 [1st Edition August 1998]
- http://perl.oreilly.com/cookbook/
+ http://perl.oreilly.com/catalog/cookbook/
If you're already a seasoned programmer, then the Camel Book might
suffice for you to learn Perl from. If you're not, check out the
=head1 NAME
-perlfaq3 - Programming Tools ($Revision: 1.31 $, $Date: 2003/01/03 20:10:11 $)
+perlfaq3 - Programming Tools ($Revision: 1.32 $, $Date: 2003/01/26 17:41:53 $)
=head1 DESCRIPTION
=head2 Is there a Perl shell?
-In general, not yet. There is psh available at
-
- http://www.focusresearch.com/gregor/psh
-
-Which includes the following description:
-
- The Perl Shell is a shell that combines the interactive nature
- of a Unix shell with the power of Perl. The goal is to eventually
- have a full featured shell that behaves as expected for normal
- shell activity. But, the Perl Shell will use Perl syntax and
- functionality for control-flow statements and other things.
+The psh (Perl sh) is currently at version 1.8. The Perl Shell is a
+shell that combines the interactive nature of a Unix shell with the
+power of Perl. The goal is a full featured shell that behaves as
+expected for normal shell activity and uses Perl syntax and
+functionality for control-flow statements and other things.
+You can get psh at http://www.focusresearch.com/gregor/psh/ .
The Shell.pm module (distributed with Perl) makes Perl try commands
which aren't part of the Perl language as shell commands. perlsh
=head1 NAME
-perlfaq4 - Data Manipulation ($Revision: 1.39 $, $Date: 2003/01/03 20:06:21 $)
+perlfaq4 - Data Manipulation ($Revision: 1.40 $, $Date: 2003/01/26 17:43:21 $)
=head1 DESCRIPTION
=item How do I convert from decimal to hexadecimal
-Using sprint:
+Using sprintf:
$hex = sprintf("%X", 3735928559);
=head2 How do I pad a string with blanks or pad a number with zeroes?
-(This answer contributed by Uri Guttman, with kibitzing from
-Bart Lateur.)
-
In the following examples, C<$pad_len> is the length to which you wish
to pad the string, C<$text> or C<$num> contains the string to be padded,
and C<$pad_char> contains the padding character. You can use a single
C<$pad_len>.
# Left padding a string with blanks (no truncation):
- $padded = sprintf("%${pad_len}s", $text);
+ $padded = sprintf("%${pad_len}s", $text);
+ $padded = sprintf("%*s", $pad_len, $text); # same thing
# Right padding a string with blanks (no truncation):
- $padded = sprintf("%-${pad_len}s", $text);
+ $padded = sprintf("%-${pad_len}s", $text);
+ $padded = sprintf("%-*s", $pad_len, $text); # same thing
# Left padding a number with 0 (no truncation):
- $padded = sprintf("%0${pad_len}d", $num);
+ $padded = sprintf("%0${pad_len}d", $num);
+ $padded = sprintf("%0*d", $pad_len, $num); # same thing
# Right padding a string with blanks using pack (will truncate):
$padded = pack("A$pad_len",$text);
print "@lines"; # WRONG - extra blanks
print @lines; # right
-=head2 Why don't my <<HERE documents work?
+=head2 Why don't my E<lt>E<lt>HERE documents work?
Check for these three things:
=over 4
-=item There must be no space after the << part.
+=item There must be no space after the E<lt>E<lt> part.
=item There (probably) should be a semicolon at the end.
=head1 NAME
-perlfaq5 - Files and Formats ($Revision: 1.27 $, $Date: 2002/12/06 07:40:11 $)
+perlfaq5 - Files and Formats ($Revision: 1.28 $, $Date: 2003/01/26 17:45:46 $)
=head1 DESCRIPTION
See also the new L<perlopentut> if you have it (new for 5.6).
-=head2 Why do I sometimes get an "Argument list too long" when I use <*>?
+=head2 Why do I sometimes get an "Argument list too long" when I use E<lt>*E<gt>?
The C<< <> >> operator performs a globbing operation (see above).
In Perl versions earlier than v5.6.0, the internal glob() operator forks
=back
-=head2 Why can't I just open(FH, ">file.lock")?
+=head2 Why can't I just open(FH, "E<gt>file.lock")?
A common bit of code B<NOT TO USE> is this:
=head1 NAME
-perlfaq7 - General Perl Language Issues ($Revision: 1.12 $, $Date: 2002/12/06 07:40:11 $)
+perlfaq7 - General Perl Language Issues ($Revision: 1.13 $, $Date: 2003/01/26 17:45:46 $)
=head1 DESCRIPTION
are effectively shallowly bound. Consider this just one more reason
not to use them. See the answer to L<"What's a closure?">.
-=head2 Why doesn't "my($foo) = <FILE>;" work right?
+=head2 Why doesn't "my($foo) = E<lt>FILEE<gt>;" work right?
C<my()> and C<local()> give list context to the right hand side
of C<=>. The <FH> read operation, like so many of Perl's
=head1 NAME
-perlfaq8 - System Interaction ($Revision: 1.16 $, $Date: 2003/01/03 20:03:57 $)
+perlfaq8 - System Interaction ($Revision: 1.17 $, $Date: 2003/01/26 17:44:04 $)
=head1 DESCRIPTION
=head2 How do I use an SQL database?
-There are a number of excellent interfaces to SQL databases. See the
-DBD::* modules available from http://www.cpan.org/modules/by-module/DBD/ .
-A lot of information on this can be found at http://dbi.perl.org/
+The DBI module provides an abstract interface to most database
+servers and types, including Oracle, DB2, Sybase, mysql, Postgresql,
+ODBC, and flat files. The DBI module accesses each database type
+through a database driver, or DBD. You can see a complete list of
+available drivers on CPAN: http://www.cpan.org/modules/by-module/DBD/ .
+You can read more about DBI on http://dbi.perl.org .
+
+Other modules provide more specific access: Win32::ODBC, Alzabo, iodbc,
+and others found on CPAN Search: http://search.cpan.org .
=head2 How do I make a system() exit on control-C?