-
Notifications
You must be signed in to change notification settings - Fork 561
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update perlfaq to CPAN version 5.20191102
[DELTA] 5.20191102 2019-11-02 05:34:43Z * fix bad pod markup in perlfaq8 (PR #78; thanks, Joaquín Ferrero!) * remove stale section about lib.pm (PR #82, Dan Book) * update perlfaq9 to reference Email::Stuffer (PR #79, Dan Book) * update perlfaq9 to reference URL::Search (PR #80, Dan Book) * update perlfaq9 to use HTTP::Tiny (PR #81, Dan Book) * fix some broken links (issue #71, dctabuyz)
- Loading branch information
1 parent
17446f3
commit a592016
Showing
14 changed files
with
79 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/Changes | ||
/LICENSE | ||
/MANIFEST | ||
/META.json | ||
/META.yml | ||
/README | ||
/dist.ini | ||
/inc/ | ||
/t/00-compile.t | ||
/xt/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ use strict; | |
use warnings; | ||
package perlfaq; | ||
|
||
our $VERSION = '5.20190126'; | ||
our $VERSION = '5.20191102'; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ perlfaq4 - Data Manipulation | |
|
||
=head1 VERSION | ||
|
||
version 5.20190126 | ||
version 5.20191102 | ||
|
||
=head1 DESCRIPTION | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ perlfaq5 - Files and Formats | |
|
||
=head1 VERSION | ||
|
||
version 5.20190126 | ||
version 5.20191102 | ||
|
||
=head1 DESCRIPTION | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ perlfaq9 - Web, Email and Networking | |
|
||
=head1 VERSION | ||
|
||
version 5.20190126 | ||
version 5.20191102 | ||
|
||
=head1 DESCRIPTION | ||
|
||
|
@@ -95,29 +95,30 @@ L<HTML::LinkExtor> or L<HTML::Parser>. You might even use | |
L<HTML::SimpleLinkExtor> as an example for something specifically | ||
suited to your needs. | ||
|
||
You can use L<URI::Find> to extract URLs from an arbitrary text document. | ||
You can use L<URI::Find> or L<URL::Search> to extract URLs from an | ||
arbitrary text document. | ||
|
||
=head2 How do I fetch an HTML file? | ||
|
||
(contributed by brian d foy) | ||
|
||
Use the libwww-perl distribution. The L<LWP::Simple> module can fetch web | ||
resources and give their content back to you as a string: | ||
The core L<HTTP::Tiny> module can fetch web resources and give their | ||
content back to you as a string: | ||
|
||
use LWP::Simple qw(get); | ||
use HTTP::Tiny; | ||
|
||
my $html = get( "http://www.example.com/index.html" ); | ||
my $ua = HTTP::Tiny->new; | ||
my $html = $ua->get( "http://www.example.com/index.html" )->{content}; | ||
|
||
It can also store the resource directly in a file: | ||
|
||
use LWP::Simple qw(getstore); | ||
$ua->mirror( "http://www.example.com/index.html", "foo.html" ); | ||
|
||
getstore( "http://www.example.com/index.html", "foo.html" ); | ||
|
||
If you need to do something more complicated, you can use | ||
L<LWP::UserAgent> module to create your own user-agent (e.g. browser) | ||
to get the job done. If you want to simulate an interactive web | ||
browser, you can use the L<WWW::Mechanize> module. | ||
If you need to do something more complicated, the L<HTTP::Tiny> object can | ||
be customized by setting attributes, or you can use L<LWP::UserAgent> from | ||
the libwww-perl distribution or L<Mojo::UserAgent> from the Mojolicious | ||
distribution to make common tasks easier. If you want to simulate an | ||
interactive web browser, you can use the L<WWW::Mechanize> module. | ||
|
||
=head2 How do I automate an HTML form submission? | ||
|
||
|
@@ -126,25 +127,26 @@ and forms or a web site, you can use L<WWW::Mechanize>. See its | |
documentation for all the details. | ||
|
||
If you're submitting values using the GET method, create a URL and encode | ||
the form using the C<query_form> method: | ||
the form using the C<www_form_urlencode> method from L<HTTP::Tiny>: | ||
|
||
use HTTP::Tiny; | ||
|
||
use LWP::Simple; | ||
use URI::URL; | ||
my $ua = HTTP::Tiny->new; | ||
|
||
my $url = url('L<http://www.perl.com/cgi-bin/cpan_mod')>; | ||
$url->query_form(module => 'DB_File', readme => 1); | ||
$content = get($url); | ||
my $query = $ua->www_form_urlencode([ q => 'DB_File', lucky => 1 ]); | ||
my $url = "https://metacpan.org/search?$query"; | ||
my $content = $ua->get($url)->{content}; | ||
|
||
If you're using the POST method, create your own user agent and encode | ||
the content appropriately. | ||
If you're using the POST method, the C<post_form> method will encode the | ||
content appropriately. | ||
|
||
use HTTP::Request::Common qw(POST); | ||
use LWP::UserAgent; | ||
use HTTP::Tiny; | ||
|
||
my $ua = LWP::UserAgent->new(); | ||
my $req = POST 'L<http://www.perl.com/cgi-bin/cpan_mod'>, | ||
[ module => 'DB_File', readme => 1 ]; | ||
my $content = $ua->request($req)->as_string; | ||
my $ua = HTTP::Tiny->new; | ||
|
||
my $url = 'https://metacpan.org/search'; | ||
my $form = [ q => 'DB_File', lucky => 1 ]; | ||
my $content = $ua->post_form($url, $form)->{content}; | ||
|
||
=head2 How do I decode or create those %-encodings on the web? | ||
X<URI> X<URI::Escape> X<RFC 2396> | ||
|
@@ -287,26 +289,18 @@ your policy says it is. You really are best off asking the user. | |
|
||
=head2 How do I send email? | ||
|
||
Use the L<Email::MIME> and L<Email::Sender::Simple> modules, like so: | ||
Use the L<Email::Stuffer> module, like so: | ||
|
||
# first, create your message | ||
my $message = Email::MIME->create( | ||
header_str => [ | ||
From => '[email protected]', | ||
To => '[email protected]', | ||
Subject => 'Happy birthday!', | ||
], | ||
attributes => { | ||
encoding => 'quoted-printable', | ||
charset => 'utf-8', | ||
}, | ||
body_str => "Happy birthday to you!\n", | ||
); | ||
|
||
use Email::Sender::Simple qw(sendmail); | ||
sendmail($message); | ||
|
||
By default, L<Email::Sender::Simple> will try `sendmail` first, if it exists | ||
my $message = Email::Stuffer->from('[email protected]') | ||
->to('[email protected]') | ||
->subject('Happy birthday!') | ||
->text_body("Happy birthday to you!\n"); | ||
|
||
$message->send_or_die; | ||
|
||
By default, L<Email::Sender::Simple> (the C<send> and C<send_or_die> methods | ||
use this under the hood) will try C<sendmail> first, if it exists | ||
in your $PATH. This generally isn't the case. If there's a remote mail | ||
server you use to send mail, consider investigating one of the Transport | ||
classes. At time of writing, the available transports include: | ||
|
@@ -326,14 +320,9 @@ uses TLS or SSL and can authenticate to the server via SASL. | |
|
||
=back | ||
|
||
Telling L<Email::Sender::Simple> to use your transport is straightforward. | ||
Telling L<Email::Stuffer> to use your transport is straightforward. | ||
|
||
sendmail( | ||
$message, | ||
{ | ||
transport => $email_sender_transport_object, | ||
} | ||
); | ||
$message->transport($email_sender_transport_object)->send_or_die; | ||
|
||
=head2 How do I use MIME to make an attachment to a mail message? | ||
|
||
|
@@ -342,6 +331,15 @@ objects themselves are parts and can be attached to other L<Email::MIME> | |
objects. Consult the L<Email::MIME> documentation for more information, | ||
including all of the supported methods and examples of their use. | ||
|
||
L<Email::Stuffer> uses L<Email::MIME> under the hood to construct | ||
messages, and wraps the most common attachment tasks with the simple | ||
C<attach> and C<attach_file> methods. | ||
|
||
Email::Stuffer->to('[email protected]') | ||
->subject('The file') | ||
->attach_file('stuff.csv') | ||
->send_or_die; | ||
|
||
=head2 How do I read email? | ||
|
||
Use the L<Email::Folder> module, like so: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ perlglossary - Perl Glossary | |
|
||
=head1 VERSION | ||
|
||
version 5.20190126 | ||
version 5.20191102 | ||
|
||
=head1 DESCRIPTION | ||
|
||
|