Perl 5 Porters Mailing List Summary: January 23rd-29th
Hey everyone,
Following is the p5p (Perl 5 Porters) mailing list summary for the past week.
Enjoy!
|
このページは大阪弁化フィルタによって翻訳生成されたんですわ。 |
Hey everyone,
Following is the p5p (Perl 5 Porters) mailing list summary for the past week.
Enjoy!
At YAPC::EU 2016 I gave a talk on my approach to developing code against RESTful services. The talk starts out a little silly, but my aim was to show some of the frustrations that can arise when developing aforementioned code. My conclusion is that you should write an emulator for any service you are developing against. Not just that but release an emulator for any RESTful APIs you are developing for others so they can trivially test their client code.
Of course I am a developer so inherently lazy, and being a perl developer I am especially lazy. Having done the emulation dance for at least three modules I've written I suggested I would write something to make this easier. I managed to find some time last week, amongst our annual developer's conference, to do this.
Perl Challenge: What characters do the following regex character
classes include?
? [--^]
? [^-^]
? [-^]
? [^--^]
? [^-]
? [^^]
Answers tomorrow!
Some time back we added support to Perl for locked or restricted hashes. (See Hash::Util and fields.pm). The basic idea is that you can set up a hash, and then "lock" it, at which point access to unregistered keys in the hash, either write OR read, will cause an exception.
The basic idea was to work around Perl's lack of a true "struct"/"object" where it would be conventional to have compile time exceptions when accessing a non-existent member, or when accessing a late bound object in many languages which should produce a run time exception. Unfortunately restricted hashes do not support compile time exceptions, so we only get run time exceptions.
Listing BitBucket repositories could be annoying task even though BitBucket exposes a Rest API for this, and the reason for it is pagination - BitBucket sends result back spited by pages, so you need to request a next page till the end. This is hard to automate and prevent me form using BitBucket API directly.
Well, I have dropped a small sparrow plugin to handle with this task. At least it works for me. It lists ( in plain text format ) all the repositories for given project and team. There a lot of option of plugin you will find at documentation but the usual workflow is:
$ sparrow plg install bitbucket-repo-list
Here you lists repositories for given project and team. You should supply your Bitbucket credentials to request team/project information:
$ sparrow plg run bitbucket-repo-list \
--param login=superuser --param password=keep-it-secret \
--param team=heroes \
--param project=humans
That is it. Hopefully will be useful for someone deal with BitBucket repositories.
Everyone (I’d
have to assume) has written the two basic sort functions
? # sort strings
case-insensitively
? sub insensitive {
??? return uc $a cmp uc $b || $a cmp $b;
? }
and
? # sort values
numerically
? sub numeric {
??? return $a <=> $b;
? }
Here are three
fun―and hopefully useful―sort functions.
This first one
sorts strings with
numeric suffixes (such as room numbers like “White 102”) first by the string
part, then numerically by the suffix. The function assumes the data has been vetted;
i.e. matches $rgx_strnum. Obviously
you may need to tweak $rgx_strnum to meet your specific
needs; you can also add calls to uc to sort the
string part case-insensitively.
? our $rgx_strnum = qr/^([A-Za-z]+)\s*(\d+)$/;
? sub strnum {
? ??my ($aS, $aN) = $a =~ $rgx_strnum;
? ??my ($bS, $bN) = $b =~ $rgx_strnum;
? ??return $aS cmp $bS || $aN <=> $bN;
? }
This function sort
strings ASCIIbetically except blank strings sort to the end―I am always
surprised how often this comes up. As above, you can add calls to uc for a case-insensitive blanks-last sort.
This is a tutorial as much as it is a request for guidance from experienced XS/C/perlguts folks, as TIMTOWTDI, and in this case, likely, a better way.
This will show you how to pass a Perl array reference (aref) into a C function, convert the aref into a C array, work on it, then push it back onto the stack so the C function returns it as a Perl array.
It'll also show that although we bite off of
Inline::C,
the XS code it generates can be used in your distribution, even without the end-user needing Inline installed.
First, straight to the code. Comments inline for what's happening (or, at least, what I think is happening... feedback welcomed):
Well, all of the learning and testing I've done with C, XS, managing bits, reading and understanding hardware datatsheets etc in the last few months is really starting to pay off, with a lot of kudos going out to many Perlers for providing guidance and help with my questions, particularly with XS and C.
We now have reliable, working Perl code to output and receive input analog signals on the Raspberry Pi. This example uses an MCP41010 digital potentiometer for the analog out, and an ADC1015 analog to digital converter for analog in. I still have two different ADCs to write code for, two more models of digital pots, and later this week I should be receiving my DACs (digital to analog converter), my GPS receiver chip, and my MCP3004/8 ADCs.
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is hosted by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.