Dist::Zilla Needs Support The first

It is support day here at the Dist-Pen

Today I am going to look a the [Support] section plug-in. This is one of the more fancy plug-in that I have looked as so far as it tries to add in not one section but up to four all under the 'Support' section.
The four are 'Perl Doc', 'Websites', 'Bugs / Feature Requests' and 'Source Code'

Obviously this plug-in will be very useful on large projects that may need for all four of the sections or perhaps the lazy programer who wants to cover off a number of things with only one plug-in.

The first thing I have to do is get rid of all the similar content I have been adding over the past few posts

Perl Challenge: Fun with Character Classes

Perl Challenge: What characters do the following regex character classes include?

  [--^]
  [^-^]
  [-^]
  [^--^]
  [^-]
  [^^]

Answers tomorrow!

Are Restricted/Locked Hashes A Failed Experiment?

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.

How to list BitBucket repositories with sparrow

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:

install plugin

$ sparrow plg install bitbucket-repo-list

run plugin

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.

Dist::Zilla Gets Used

Post-ette day here in the Dist-Pen

Today I am going to have a quick look at the [Requires] section plug-in. As the name implies this plug-in will add in a 'Requires' section in your POD. It will snoop though your '.pm' and '.pl' files with 'Module::Extract::Use' and lists these out.

Now I do have large number of uses in my code so I gave it a quick go by first installing the plug-in and then adding

[Generic / SYNOPSIS]
++[Requires]
[Generic / DESCRIPTION]
to my 'weaver.ini' file and then after a dzil clean and build I get;

Three Sort Functions

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.

Send in a Perl aref to C, get back a Perl array (and using the generated XS)

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):

The Perl Foundation Grant Committee is looking for new members

If you're looking for ways to be more involved and have more influence, here's your chance!

The Perl Foundation's Grant Committee is looking for new members to the Committee Member position and the Committee Secretary position.

You can find more information on TPF blog.

Dist::Zilla Gets More Legal

It is Legal day again here in the Dist-Pen.

So a quick look today at three section plug-ins all dealing with the LEGAL section of you pod. All three offer the same basic output as the [Legal] sections we saw in this post, buit each adds a little.

So to start lets have a look at [Legal::Complicated] the name is a little misleading as the plug-in is easy to use and by complicated it meas that the license holder is more complicated that a single author. This plug-in is best used when code is coming from an organization where ownership is shared between the organization and the writer of the code.

This plug-in works with comment tags your add to any of the PODs you want to have extra content on. There are three you can use '# AUTHOR:', '# OWNER:' and '#LICENSE:'. I don't really have a use for this plug-in in my project but here is an example of how to use it.

Saying of the day...

When your hammer is Perl, every other language looks like a nail!

Dancer2 0.204003 fixes missing dependencies, improves error handling

Dancer2 0.204003 is on its way to CPAN now, and provides the following changes:

  • The CPANTS testing service reported that some dependencies for Dancer2 were not specified in the distribution. This has been corrected, and we apologize for any issues this may have caused.
  • When a route exception occurred, Dancer2 would catch the error first, and would prevent any custom exception handling from trapping the exception. There were some ugly hacks for working around this, but this fix puts things right, and lets the exception hook fire first, and then will trap the error.
  • Several changes were made to Dancer2’s Template Toolkit integration, the most significant of which being the removal of the ANYCASE option.
  • Various documentation improvements.

A big thank you to those who contributed to this release and helped get it out the door.

The full changelog is as follows:

Bit string manipulation made easy with Bit::Manip

I've been writing a lot of software lately that deals with direct hardware access (specifically analog and digital hardware for the Raspberry Pi). This means that I've had to learn some C, as well as get proficient with bit manipulation and the bitwise operators.

As part of my learning, I thought I'd write a module to do this bit manipulation for me, hence Bit::Manip was born. (There's also a Bit::Manip::PP for those who can't/don't want to use XS. It should be indexed shortly).

Here's a scenario based example of how the software can be used.

You have a 16-bit configuration register for a piece of hardware that you want to configure and send in. Here's the bit configuration

Dist::Zilla Re-Generates

Still stuck in weaver land here in the Dist-pen

Today I am going to look at [GenerateSection] section plug-in. This one look very interesing to me as it lets on generate a section from with-in the 'weaver.ini' file.

Now in my case I would love to have a common header and footer for my Tutorial pod without having to add the same section over and over again in each POD doc. I am hoping that this plug-in will get most if not all of what I need.

Right now I am just going to go for a simple all text version for now as I am not 100% sure how to get extra variable content into Dist::Zilla and Pod::Weaver.

So I would like to get something like this

Perl Aventure Series Part 2

A couple weeks ago we had our first meeting for the Perl Adventure Series. Despite a terrible ice storm we still had 3 new people turn out in addition to our regular cast of characters. I hope we see them (and more) back. 

During the meetup we set up our Dist::Zilla config file, and a new GitHub repository for the adventure series. And we got started designing the mission data structure. 

We had a great time discussing all the implications of this design. There was a heated argument about including code snippets inside the config file in order to keep the game engine generic. However, I’m going to argue to the group that we should be putting these code snippets out into individual modules (or perhaps roles) and then just name those plugins in the config file. I hate the idea of code in a config file. It makes my skin crawl. 

Strawberry Perl 5.24.1.1 + 5.22.3.1 released

Strawberry Perl 5.24.1.1 and 5.22.3.1 are available at http://strawberryperl.com

More details in Release Notes:
http://strawberryperl.com/release-notes/5.24.1.1-64bit.html
http://strawberryperl.com/release-notes/5.24.1.1-32bit.html
http://strawberryperl.com/release-notes/5.22.3.1-64bit.html
http://strawberryperl.com/release-notes/5.22.3.1-32bit.html

I would like to thank our sponsor Enlightened Perl Organisation for resources provided to our project.

Swapping Things

So we all know the COMPSCI 101 method of swapping two variables:
  $tmp = $x; $x = $y; $y = $tmp;
And we all know the better way of doing it:
  ($x, $y) = ($y, $x);

And yet, I found the following in PRODUCTION CODE, that a contractor was PAID ACTUAL DOLLARS TO WRITE:
  ($tmp_x, $tmp_y) = ($x, $y);
  ($x, $y) = ($tmp_y, $tmp_x);
Weird that they knew about parallel assignment but not that you could just apply it to two variables directly.

Anyhow, this wasn’t nearly as bad as the code I found in a different module (same vendor) to swap all the 1s and 0s in a string. Now this is a somewhat less trivial problem than simply swapping two variables, but
  $str =~ tr/01/10/;
does the job nicely. Alas, in the same vein as the variable-swap, the method that vendor went with was:
  $str =~ s/0/2/g;
  $str =~ s/1/3/g;
  $str =~ s/2/1/g;
  $str =~ s/3/0/g;

Good thing $str doesn’t contain any 2 s or 3 s!

Dist::Zilla Consumes Even More

Back to do some more Sections here in the Dist-pen today.

Today I am going to look at three plug-ins the very simple [Extends] the equally simple [MooseExtends] the little different [MooseConsumes]

The first two do what you would expect. Create an 'EXTENDS' section in your POD that lists all the modules that your '.pm' file is based on.

The first one [Extends] loops though the '@isa' and plucks the information from there. Now for kicks I installed this one and added it to my 'weaver.ini' and I got


=head1 EXTENDS
=over 4
=item * L<Moose::Meta::Class::__ANON__::SERIAL::37>
=back
after a clean an build, So this is not a plug-in that I would use with a Moose class.

SPI bus access, analog in/out on the Raspberry Pi powered by Perl

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.

Perl 5 Porters Mailing List Summary: January 16th-22nd

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week.

Enjoy!

An informal comparison of sparrow and ansible eco systems

Hi!

Here is my latest post about Sparrowdo configuration management tool written in Perl6 - Sparrow plugins vs ansible modules - an attempt of informal comparison of sparrow and ansible eco systems.

Regards.

Alexey

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.