diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-05-24 12:26:56 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2019-05-24 12:26:56 +0100 |
| commit | a797dd9e2e57f7e13a3979fd97bcbf1ab4150678 (patch) | |
| tree | 550a3f0ad647fb93beae2b7a987397a45505f31a /challenge-009/maxim-nechaev | |
| parent | 5b3d3d48a34b14c06209e4ce75de5898ba84f09f (diff) | |
| download | perlweeklychallenge-club-a797dd9e2e57f7e13a3979fd97bcbf1ab4150678.tar.gz perlweeklychallenge-club-a797dd9e2e57f7e13a3979fd97bcbf1ab4150678.tar.bz2 perlweeklychallenge-club-a797dd9e2e57f7e13a3979fd97bcbf1ab4150678.zip | |
- Added solutions by Maxim Nechaev.
Diffstat (limited to 'challenge-009/maxim-nechaev')
| -rwxr-xr-x | challenge-009/maxim-nechaev/perl5/ch-1.pl | 13 | ||||
| -rwxr-xr-x | challenge-009/maxim-nechaev/perl5/ch-3.pl | 33 |
2 files changed, 46 insertions, 0 deletions
diff --git a/challenge-009/maxim-nechaev/perl5/ch-1.pl b/challenge-009/maxim-nechaev/perl5/ch-1.pl new file mode 100755 index 0000000000..41a8953373 --- /dev/null +++ b/challenge-009/maxim-nechaev/perl5/ch-1.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl -w +use strict; +use feature 'say'; + +my $n = 0; +for ( my ($k, %d) = 1; keys %d != 5; $k++ ) { + # next square number + $n += 2*$k - 1; + + # %d distinct digits in $n + %d = map { $_ => $_ } split '', $n; +} +say $n; diff --git a/challenge-009/maxim-nechaev/perl5/ch-3.pl b/challenge-009/maxim-nechaev/perl5/ch-3.pl new file mode 100755 index 0000000000..001c32f581 --- /dev/null +++ b/challenge-009/maxim-nechaev/perl5/ch-3.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w +use strict; +use utf8; +use Encode; +use Email::Sender::Transport::SMTP; +use Email::Sender::Simple qw/sendmail/; +use MIME::Entity; + +my $SparkpostAPIKey = '3d349e3c7f7c309a6b2be80bca6f4f9e0c7d1621'; +my $toEmail = 'maxim@nechaev.net'; +my $fromEmail = 'sparkpost@nechaev.net'; + +# docs https://developers.sparkpost.com/api/smtp/ +my $sparkpost = Email::Sender::Transport::SMTP->new({ + host => 'smtp.sparkpostmail.com', + port => 587, + ssl => 'starttls', + sasl_username => 'SMTP_Injection', + sasl_password => $SparkpostAPIKey, +}); + +my $email = MIME::Entity->build( + Type => 'text/plain', + Encoding => 'quoted-printable', + Charset => 'UTF-8', + To => encode('MIME-Header', 'Perl Hacker') . " <$toEmail>", + From => encode('MIME-Header', 'Sparkpost' ) . " <$fromEmail>", + Subject => encode('MIME-Header', 'Email through Sparkpost'), + Data => 'This email from perl script using Sparkpost API', + #'X-MSYS-API' => '{"options": { "sandbox" : true }}', +); + +sendmail( $email, { transport => $sparkpost } ); |
