So I Guess I'm Back

Hi… remember me?

Been away a while, and now I have a whole heap of bug reports to get through. But you, dear reader, I'm giving the inside track. If there's a bug in one of my modules and you want me to prioritize it, comment below.

Also, how are you doing?

I'm good.

c:

Turkish speaker needed

A very kind person has submitted a Turkish translation for FormFu.

We're hoping another kind Turkish speaker could find a few moments to read over the submission and check it's good to go.

PR at -> https://github.com/FormFu/HTML-FormFu/pull/43

Not Comparing The Way You Meant

Here’s another example of code taken, terrifyingly, from a script that a contractor was paid cash money to write. The contractor’s code included a script to remote into another system and perform a command. Most systems required ssh, but we had some older systems that required rsh instead. So the contractor made a configuration file that contained client definitions:

  {
     "ferrari" : {
        "method": "ssh", "ipaddr": "10.26.101.92"
     },
     "yugo" : {
        "method": "rsh", "ipaddr": "10.25.34.112"
     }
  }

In the script, he looked up the client in question, and put its configuration into variables like $method. So far, so good. But here’s the code that decides which access method to use:

  if (method == "ssh") {
    do_ssh($ipaddr, $command);
  }
  else {
    do_rsh($ipaddr, $command);
  }

So this code omits the sigil on $method—problem #1—and thus treats method as a bareword (i.e. the literal string "method"), then compares that to the literal string "ssh", but does so NUMERICALLY—problem #2. Since both are non-numeric strings, they are both treated as 0, and the comparison is always true. Needless to say, this script did not turn on warnings or strict mode—problem #3. Luckily, the vast majority of our critical systems required ssh, and on those systems, three wrongs made a “right!”


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!

Emulating Just About Any RESTful JSON API

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

About blogs.perl.org

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.