Following a full day of two talk tracks we're happy to say there will be not one, but two after event opportunities to chat with your fellow LPW attendees. The first will be drinks at the event until 19:15, featuring (among other things) craft beer brewed right here in London!
As with everything else, this wouldn't be possible without our sponsors and so we'd like to thank Perl Careers, a long time supporter of LPW for their gold sponsorship.
Perl Careers and it’s buddy CareersJS are a technical focused recruitment consultancy, run by a CPAN & npm contributor with a recruitment background, rather than by a non-technical person. I can understand the skills you're looking to hire for, make sense of your GitHub profile, and offer specific Perl-related career and salary advice. I am very picky about only recruiting for companies I'd want to work at, and placing candidates who I'd want to work with. I'd love to talk to you if you think you might be either.
In my last post I got nicely snookered by the S3 call 'GetBucketLocation' which was one of the call that had a 'todo' test.
The XML coming back from ASW is correct
<?xml version="1.0" encoding="UTF-8"?>
<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-0301/">
EU
</LocationConstraint>
but no matter what I tried on 'XML::Simple' I could not get it to parse just the way I want though I did get very close with this
I've been working with Sawyer X and Stevan Little to try to bring OO into the Perl core. Most of this work is based on Stevan's work, with me trying to add a final "polish" layer to make it clean and still feel like Perl.
It's being called "Cor" to distinguish it from current OO systems.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (October 20, 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.
Challenge # 1: Sunday Christmas
Write a script to list dates for Sunday Christmas between 2019 and 2100. For example, 25 Dec 2022 is Sunday.
Christmas on Sunday in Perl 5
I'll be using the Time::Local core module which provides reciprocal functions of the gmtime and localtime built-in functions.
Write a script to demonstrate brace expansion. For example, the script would take the command line argument Perl {Daily,Weekly,Monthly,Yearly} Challenge and should expand it and print like below:
You’ve probably heard about the glob function. It can expand wildcards like * or ?, so you e.g. can easily check what files correspond to p*.p?. But glob can do one more thing for us: brace expansion.
Well carrying on with my quest to clean up the Paws S3 code I decided while I am waiting for my last batch of changes to be reviewed I decided to review some of the 'TODO' tests.
TODO passed: 6364, 6370, 7896, 10045, 10052, 10137
First a 'TODO' test is a stubbed in test that will most likely fail and if it does it will not effect the final Pass/Fail of test case. It is basically one of these
The first one I am going to play with is 's3-get-bucket-location.response.test.yml which looks like this
---
todo: 'S3 is not stable'
call: GetBucketLocation
service: S3
tests:
- expected: EU
op: eq
path: LocationConstraint
So the first thing I did was chop off that 'todo' line;
---
--todo: 'S3 is not stable'
call: GetBucketLocation
service: S3
…
and then check the content in the '3-get-bucket-location.response';
I am in favor of this change, because it reflects an ancient wisdom:
"No one sews a patch of unshrunk cloth on an old garment, for the patch will pull away from the garment, making the tear worse. Neither do people pour new wine into old wineskins. If they do, the skins will burst; the wine will run out and the wineskins will be ruined. No, they pour new wine into new wineskins, and both are preserved."
SPVM is Static Perl Virtual Machine. I write an example to sum even numbers with precompiling.
Using precompiling, the source code is output to C source code and it is compiled to machine code. This performance is same as C language in add operation! You are surprised.
Anyone have information on the current and future status of Stratopan?
Still marked a "Beta", the latest perl version is stuck on 5.27.2, the blog.stratopan and cpan.stratopan http sites error, and the https version redirect back to www.
I left off in my last post with all my bits and bods to get the proper structure in my generated perl class from the Json data. Now I have to get the 'status' out of the response and then into my class.
By now I know where to start to look to in the code to apply my changes. I started in Paws::Net::RestXMLResponse' class at its 'process' sub which looks at the response 'status' and takes either the error path (>=300) or the happy path (<300). We are interested in the happy path and that takes us to the 'response_to_object' sub.
First I can see that I have the 'status' very soon in the sub;
Spoiler Alert: This weekly challenge deadline is due in a couple of days from now (October 6, 2019). This blog post offers some solutions to this challenge, please don't read on if you intend to complete the challenge on your own.
Challenge # 1: File Type
Write a script to check the file content without explicitly reading the content. It should accept file name with path as command line argument and print “The file content is binary.” or else “The file content is ascii.” accordingly.
Write a script to check the file content without explicitly reading the content. It should accept file name with path as command line argument and print “The file content is binary.” or else “The file content is ascii.” accordingly.
Frankly, I had no idea how to solve this. I had to google the solution, and I was quite surprised Perl had the operators designed for exactly this purpose. During my approximately 20 years of Perl programming, I’ve never needed the -T and -B operators—probably because all my scripts and programs expect either a text or a binary file as the input, and it’s upon the user to provide it in the expected format.
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
say 'The file content is ', (-T shift) ? 'ascii' : 'binary', '.';
In my last post I was just getting the last parts of my new 'Satus' attribute in place having only one more part to create and that is a new 'trait' in '/lib/Paws/API.pm'
I was thinking af starting by coping the present package;
package Paws::API::Attribute::Trait::NameInRequest;
use Moose::Role;
use Moose::Util;
Moose::Util::meta_attribute_alias('NameInRequest');
has request_name => (is => 'ro', isa => 'Str');
and just changing the 'Request' for 'Response'. However looking at the role I see it is also adding a 'request_name' attribute, which I do not need, this trait is used very specially in the code the name of AWS call.
You can get a prebuilt rakudo.js from npm with a single command
npm install rakudo
I have decided not to upload the rakudo.js tarballs to CPAN (while easily doable if anybody actually want to get it from there it seems nobody would benefit from that as it seems getting it from npm will be just more convenient for everyone).
# We pass our chosen subset of roast tests in headless Chrome using puppeteer
We have a repo with a test runner that bundles up the tests using the parcel bundler and passes them to Chrome
What did I do last month? Let me guess, the short answer would be "I was managing Perl Weekly Challenge". Although it sounds so simple, it is tough task, I must admit. Having said that, I really enjoy it. I get to interact with so many great people and learn from their experience. Above all, when I receive "Thank You" message, that takes away all the pain. I simply love the positive vibes I get from each and every member of the community.
I noticed a trend in "Perl Weekly Challenge", members now trying different languages as well. Python is one such where we have had more than one solutions. If you want to know what others are doing, please do check out the blogs. Also please do follow us @PerlWChallenge, so that you don't miss out any announcements. On top of that, members discuss task as well.
I finally had a response to my question from this post about adding a new attribute '_status' to the auto-generated classes that Paws creates;
I'd try to avoid leaking HTTP details to the user by default. It's true that for this API call the HTTP Status is relevant to the caller, so exposing it seems legit.
I'd try to limit the scope of exposing the HTTP return status by adding an attribute role like https://github.com/pplu/aws-sdk-perl/blob/master/lib/Paws/API.pm#L1 that signal the response to object routines to copy the HTTP Status over to an attribute.
Ok now to translate that to something that the non-Paw dev can understand.
Don't do that! It is not a good idea to expose too much of the response from AWS. However, this is a legitimate use case so an 'attribute role' to expose the status.
It's Wednesday today, which must mean it is time to think about the weekend :-) If you are planning to come to the London Perl Workshop on Saturday, you might like to know that we'll be serving tea and coffee at registration from 9:15, with the first talk starting at 9:50. There will also be a mid-morning and mid-afternoon break with tea, coffee and some delicious snacks and all of this is only possible due to the support of our sponsors. Today we're saying thank you to cPanel - we are grateful to have them as a gold sponsor of LPW2019.
First released in 1997, cPanel & WHM is the leading web hosting control panel globally, and is preferred by most hosting service providers. Its users in an ever-growing user base prefer its familiar, feature-full, and simple interface. This interface can be used to build, manage and update a company's their entire online presence, from websites to email addresses.