From 3563ebc6250cc3540737f79a288d167633b0197b Mon Sep 17 00:00:00 2001 From: Leo Lapworth Date: Sat, 18 Feb 2012 18:38:58 +0000 Subject: [PATCH] Update perlfaq to latest 5.0150039 Also change header to be clear where perlfaq should be updated --- bin/update_faq.pl | 2 +- docs/learn/faq/perlfaq.html | 15 +++++------ docs/learn/faq/perlfaq1.html | 6 ++--- docs/learn/faq/perlfaq2.html | 6 ++--- docs/learn/faq/perlfaq3.html | 19 +++---------- docs/learn/faq/perlfaq4.html | 8 +++--- docs/learn/faq/perlfaq5.html | 19 +++---------- docs/learn/faq/perlfaq6.html | 6 ++--- docs/learn/faq/perlfaq7.html | 22 +++++++-------- docs/learn/faq/perlfaq8.html | 10 +++---- docs/learn/faq/perlfaq9.html | 52 +++++++++++++++++++++++++++--------- 11 files changed, 81 insertions(+), 84 deletions(-) diff --git a/bin/update_faq.pl b/bin/update_faq.pl index 458772045..e6582643d 100755 --- a/bin/update_faq.pl +++ b/bin/update_faq.pl @@ -122,7 +122,7 @@ =head1 DESCRIPTION # } sub page_header { - return '[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] + return '[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ diff --git a/docs/learn/faq/perlfaq.html b/docs/learn/faq/perlfaq.html index a9818cfc8..c0f20e8dd 100644 --- a/docs/learn/faq/perlfaq.html +++ b/docs/learn/faq/perlfaq.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
@@ -214,9 +214,6 @@

perlfaq3: Progr
  • Is there a pretty-printer (formatter) for Perl?

    -
  • -
  • Is there a ctags for Perl?

    -
  • Is there an IDE or Windows Perl Editor?

    @@ -584,9 +581,6 @@

    perlfaq5: Files

  • Why do I sometimes get an "Argument list too long" when I use <*>?

    -
  • -
  • Is there a leak/bug in glob()?

    -
  • How can I open a file with a leading ">" or trailing blanks?

    @@ -1048,6 +1042,9 @@

    perlfaq9

  • How do I decode a MIME/BASE64 string?

    +
  • +
  • How do I find the user's mail address?

    +
  • How do I send email?

    @@ -1079,5 +1076,5 @@

    AUTHOR AND COPYRIGHT

    This document is available under the same terms as Perl itself. Code examples in all the perlfaq documents are in the public domain. Use them as you see fit (and at your own risk with no warranty from anyone).

    -

    Version: 5.0150037

  • +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq1.html b/docs/learn/faq/perlfaq1.html index 87188b959..4d5e524d6 100644 --- a/docs/learn/faq/perlfaq1.html +++ b/docs/learn/faq/perlfaq1.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -213,5 +213,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq2.html b/docs/learn/faq/perlfaq2.html index fcd8c8114..a8be5b097 100644 --- a/docs/learn/faq/perlfaq2.html +++ b/docs/learn/faq/perlfaq2.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -193,5 +193,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq3.html b/docs/learn/faq/perlfaq3.html index e04189d01..1e15f1e14 100644 --- a/docs/learn/faq/perlfaq3.html +++ b/docs/learn/faq/perlfaq3.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -23,7 +23,6 @@
  • How do I profile my Perl programs?
  • How do I cross-reference my Perl programs?
  • Is there a pretty-printer (formatter) for Perl?
  • -
  • Is there a ctags for Perl?
  • Is there an IDE or Windows Perl Editor?
  • Where can I get Perl macros for vi?
  • Where can I get perl-mode or cperl-mode for emacs?
  • @@ -393,16 +392,6 @@

    Is there a pretty-printer

    Put that in your .exrc file (replacing the caret characters with control characters) and away you go. In insert mode, ^T is for indenting, ^D is for undenting, and ^O is for blockdenting--as it were. A more complete example, with comments, can be found at http://www.cpan.org/authors/id/TOMC/scripts/toms.exrc.gz

    -

    Is there a ctags for Perl?

    - -

    (contributed by brian d foy)

    - -

    Ctags uses an index to quickly find things in source code, and many popular editors support ctags for several different languages, including Perl.

    - -

    Exuberant ctags supports Perl: http://ctags.sourceforge.net/

    - -

    You might also try pltags: http://www.mscha.com/pltags.zip

    -

    Is there an IDE or Windows Perl Editor?

    Perl programs are just plain text, so any editor will do.

    @@ -464,7 +453,7 @@

    Is there an IDE or Windows Perl

    http://padre.perlide.org/

    -

    Padre is cross-platform IDE for Perl written in Perl using wxWidgets to provide a native look and feel. It's open source under the Artistic License.

    +

    Padre is cross-platform IDE for Perl written in Perl using wxWidgets to provide a native look and feel. It's open source under the Artistic License. It is one of the newer Perl IDEs.

    PerlBuilder
    @@ -1017,5 +1006,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq4.html b/docs/learn/faq/perlfaq4.html index 1204b1563..dcacb2f38 100644 --- a/docs/learn/faq/perlfaq4.html +++ b/docs/learn/faq/perlfaq4.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -674,7 +674,7 @@

    How do I find matching/nesting

    To find something between two single characters, a pattern like /x([^x]*)x/ will get the intervening bits in $1. For multiple ones, then something more like /alpha(.*?)omega/ would be needed. For nested patterns and/or balanced expressions, see the so-called (?PARNO) construct (available since perl 5.10). The CPAN module Regexp::Common can help to build such regular expressions (see in particular Regexp::Common::balanced and Regexp::Common::delimited).

    -

    More complex cases will require to write a parser, probably using a parsing module from CPAN, like Regexp::Grammars, Parse::RecDescent, Parse::Yapp, Text::Balanced, or Marpa.

    +

    More complex cases will require to write a parser, probably using a parsing module from CPAN, like Regexp::Grammars, Parse::RecDescent, Parse::Yapp, Text::Balanced, or Marpa::XS.

    How do I reverse a string?

    @@ -2198,5 +2198,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples in this file are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq5.html b/docs/learn/faq/perlfaq5.html index c2a446f79..8a8cc3ad8 100644 --- a/docs/learn/faq/perlfaq5.html +++ b/docs/learn/faq/perlfaq5.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -33,7 +33,6 @@
  • How can I translate tildes (~) in a filename?
  • How come when I open a file read-write it wipes it out?
  • Why do I sometimes get an "Argument list too long" when I use <*>?
  • -
  • Is there a leak/bug in glob()?
  • How can I open a file with a leading ">" or trailing blanks?
  • How can I reliably rename a file?
  • How can I lock a file?
  • @@ -255,11 +254,7 @@

    perl -ni -e 'print unless /d/' inFile.txt - - ... or ... - - perl -pi -e 'next unless /d/' inFile.txt +
        perl -ni -e 'print if /d/' inFile.txt

    How do I count the number of lines in a file?

    @@ -722,12 +717,6 @@

    Why do I s

    To get around this, either upgrade to Perl v5.6.0 or later, do the glob yourself with readdir() and patterns, or use a module like File::Glob, one that doesn't use the shell to do globbing.

    -

    Is there a leak/bug in glob()?

    - -

    (contributed by brian d foy)

    - -

    Starting with Perl 5.6.0, glob is implemented internally rather than relying on an external resource. As such, memory issues with glob aren't a problem in modern perls.

    -

    How can I open a file with a leading ">" or trailing blanks?

    (contributed by Brian McCauley)

    @@ -1240,5 +1229,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples here are in the public domain. You are permitted and encouraged to use this code and any derivatives thereof in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit to the FAQ would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq6.html b/docs/learn/faq/perlfaq6.html index ffb304f23..f6398a282 100644 --- a/docs/learn/faq/perlfaq6.html +++ b/docs/learn/faq/perlfaq6.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -867,5 +867,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples in this file are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq7.html b/docs/learn/faq/perlfaq7.html index 24b7cf18a..31e4806bb 100644 --- a/docs/learn/faq/perlfaq7.html +++ b/docs/learn/faq/perlfaq7.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -186,23 +186,19 @@

    How do I declare/create a structur

    How do I create a module?

    -

    (contributed by brian d foy)

    - -

    perlmod, perlmodlib, perlmodstyle explain modules in all the gory details. perlnewmod gives a brief overview of the process along with a couple of suggestions about style.

    +

    perlnewmod is a good place to start, ignore the bits about uploading to CPAN if you don't want to make your module publicly available.

    -

    If you need to include C code or C library interfaces in your module, you'll need h2xs. h2xs will create the module distribution structure and the initial interface files you'll need. perlxs and perlxstut explain the details.

    +

    ExtUtils::ModuleMaker and Module::Starter are also good places to start. Many CPAN authors now use Dist::Zilla to automate as much as possible.

    -

    If you don't need to use C code, other tools such as ExtUtils::ModuleMaker and Module::Starter, can help you create a skeleton module distribution.

    +

    Detailed documentation about modules can be found at: perlmod, perlmodlib, perlmodstyle.

    -

    You may also want to see Sam Tregar's "Writing Perl Modules for CPAN" ( http://apress.com/book/bookDisplay.html?bID=14 ) which is the best hands-on guide to creating module distributions.

    +

    If you need to include C code or C library interfaces use h2xs. h2xs will create the module distribution structure and the initial interface files. perlxs and perlxstut explain the details.

    How do I adopt or take over a module already on CPAN?

    -

    (contributed by brian d foy)

    - -

    The easiest way to take over a module is to have the current module maintainer either make you a co-maintainer or transfer the module to you.

    +

    Ask the current maintainer to make you a co-maintainer or transfer the module to you.

    -

    If you can't reach the author for some reason (e.g. email bounces), the PAUSE admins at modules@perl.org can help. The PAUSE admins treat each case individually.

    +

    If you can not reach the author for some reason contact the PAUSE admins at modules@perl.org who may be able to help, but each case it treated seperatly.

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq8.html b/docs/learn/faq/perlfaq8.html index 5cae37890..933f1afd7 100644 --- a/docs/learn/faq/perlfaq8.html +++ b/docs/learn/faq/perlfaq8.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -755,8 +755,8 @@

    Can I use perl to run a

    If all you want to do is pretend to be telnet but don't need the initial telnet handshaking, then the standard dual-process approach will suffice:

        use IO::Socket;             # new in 5.004
    -    my $handle = IO::Socket::INET->new('www.perl.com:80')
    -        or die "can't connect to port 80 on www.perl.com: $!";
    +    my $handle = IO::Socket::INET->new('www.perl.com:80')
    +        or die "can't connect to port 80 on www.perl.com $!";
         $handle->autoflush(1);
         if (fork()) {               # XXX: undef means failure
             select($handle);
    @@ -1130,5 +1130,5 @@ 

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples in this file are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039

    diff --git a/docs/learn/faq/perlfaq9.html b/docs/learn/faq/perlfaq9.html index 937583339..2d1fe9fa0 100644 --- a/docs/learn/faq/perlfaq9.html +++ b/docs/learn/faq/perlfaq9.html @@ -1,4 +1,4 @@ -[%# DO NOT EDIT THIS FILE, AUTO GENERATED FROM THE perlfaq -%] +[%# DO NOT EDIT THIS FILE: generated from perlfaq (https://github.com/perl-doc-cats/perlfaq) -%] [%- # Used to get info from htmlify to ttree page.import({ @@ -8,7 +8,7 @@ => "Perl Frequently Asked Questions, Perl FAQ", keywords => "perl, perl faq, perlfaq" }); - perlfaq_version = 5.0150037; + perlfaq_version = 5.0150039; -%]
    @@ -30,6 +30,7 @@
  • How do I parse a mail header?
  • How do I check a valid mail address?
  • How do I decode a MIME/BASE64 string?
  • +
  • How do I find the user's mail address?
  • How do I send email?
  • How do I use MIME to make an attachment to a mail message?
  • How do I read email?
  • @@ -57,27 +58,39 @@

    Should I use a web framework?

    Which web framework should I use?

    -

    There are many Perl web frameworks, e.g. :

    +

    There is no simple answer to this question. Perl frameworks can run everything from basic file servers and small scale intranets to massive multinational multilingual websites that are the core to international businesses.

    + +

    Below is a list of a few frameworks with comments which might help you in making a decision, depending on your specific requirements. Start by reading the docs, then ask questions on the relevant mailing list or IRC channel.

    -
    Web::Simple - A quick and easy way to build simple web applications
    +
    Catalyst
    +

    Strongly object-oriented and fully-featured with a long development history and a large community and addon ecosystem. It is excellent for large and complex applications, where you have full control over the server.

    +
    -
    Dancer - Lightweight yet powerful web application framework
    +
    Dancer
    +

    Young and free of legacy weight, providing a lightweight and easy to learn API. Has a growing addon ecosystem. It is best used for smaller projects and very easy to learn for beginners.

    +
    -
    Catalyst - Elegant MVC Web Application Framework
    +
    Mojolicious
    +

    Fairly young with a focus on HTML5 and real-time web technologies such as WebSockets.

    +
    -
    +
    Web::Simple
    +
    + +

    Currently experimental, strongly object-oriented, built for speed and intended as a toolkit for building micro web apps, custom frameworks or for tieing together existing Plack-compatible web applications with one central dispatcher.

    -

    These are just a few of the more widely used ones. All of them interact with or use Plack which is worth understanding the basics of, as there is a lot of useful Plack::Middleware.

    +
    + -

    As to which one you should use, it depends on the complexity of the site you are trying to build. Review the three listed above and see which suites your needs best. Many of them share the same MVC concepts so once you understand one it is easier to understand the others.

    +

    All of these interact with or use Plack which is worth understanding the basics of when building a website in Perl (there is a lot of useful Plack::Middleware).

    What is Plack and PSGI?

    @@ -163,8 +176,7 @@

    How do I redirect to another page?Most Perl Web Frameworks will have a mechanism for doing this, using the Catalyst framework it would be:

        $c->res->redirect($url);
    -    $c->detach();
    -    
    + $c->detach();

    If you are using Plack (which most frameworks do), then Plack::Middleware::Rewrite is worth looking at if you are migrating from Apache or have URL's you want to always redirect.

    @@ -223,6 +235,16 @@

    How do I decode a MIME/BASE64 str

    The Email::MIME module can decode base 64-encoded email message parts transparently so the developer doesn't need to worry about it.

    +

    How do I find the user's mail address?

    + +

    Ask them for it. There are so many email providers available that it's unlikely the local system has any idea how to determine a user's email address.

    + +

    The exception is for organization-specific email (e.g. foo@yourcompany.com) where policy can be codified in your program. In that case, you could look at $ENV{USER}, $ENV{LOGNAME}, and getpwuid($<) in scalar context, like so:

    + +
      my $user_name = getpwuid($<)
    + +

    But you still cannot make assumptions about whether this is correct, unless your policy says it is. You really are best off asking the user.

    +

    How do I send email?

    Use the Email::MIME and Email::Sender::Simple modules, like so:

    @@ -234,7 +256,11 @@

    How do I send email?

    To => 'friend@example.com', Subject => 'Happy birthday!', ], - body_str => 'Happy birthday to you!', + attributes => { + encoding => 'quoted-printable', + charset => 'ISO-8859-1', + }, + body_str => "Happy birthday to you!\n", ); use Email::Sender::Simple qw(sendmail); @@ -338,5 +364,5 @@

    AUTHOR AND COPYRIGHT

    Irrespective of its distribution, all code examples in this file are hereby placed into the public domain. You are permitted and encouraged to use this code in your own programs for fun or for profit as you see fit. A simple comment in the code giving credit would be courteous but is not required.

    -

    Version: 5.0150037

    +

    Version: 5.0150039