perlsphere.net perlsphere.net

Pull Request Challenge Update

So, today I got a little more progress on my task. I found an xt/perlcritic.t test, and I updated it to use severity 3. I need to remove the no refs from the perlcriticrc because I worry that I think there are more places that use it than need to… but I need to check. I’ve got most of the files passing now, and now my git status looks like this: ~/Documents/Devel/perl-App-CLI-Extension$ git status On branch master Your branch is...

perlsphere.net perlsphere.net

2015 Pull Request Challenge: At First Glance

So, I have a couple of confessions to make: I confess that sometimes I am a little judgemental of others code I confess that I am defensive when other people judge my code When I first looked at my assigned module, I confess that I started passing judgement on it. When I first started really digging into my assigned module, I confess that I seriously considered recommending that it be deprecated. I confess that I was absolutely wrong,...

perlsphere.net perlsphere.net

The 2015 CPAN Pull Request Challenge!

I saw on my Perl Weekly newsletter today that there’s a new challenge started by Neil Bowers to try to help people working more on the various CPAN modules which need work. This seems like a neat idea, and the gist of the challenge is simple: Every month you are assigned a new module to make a pull request for You get a branch You won’t get any of your own modules You won’t get the same author twice You can request a namespace...

perlsphere.net perlsphere.net

Net::AMQP::RabbitMQ Releases

This weekend I released two versions of Net::AMQP::RabbitMQ on CPAN: 0.007000 and 0.007001. The first version was the culmination of some major refactoring in how Perl types were inferred into C and AMQP types in headers, and then also adding a bunch of previously-unsupported AMQP header types into Perl. The second version was fixing an oversight where timestamp types in headers weren’t supported. I also added a manual_tests...

perlsphere.net perlsphere.net

My YAPC::NA 2014 Abstract: Re-factor Like You Mean It; Reviving Code Intentionally

Refactoring is when you renovate code, bringing it up to par with newer parts of your application and more modern or newly-learned best practices. It can be as simple as iteratively updating core functionality or it can be as large as complete re-writes of certain systems. I will walk you through how to: Know when and where to start on my refactoring project, and why one might even want to do it. Help users, developers, and...

perlsphere.net perlsphere.net

Exceptions in Perl, Then and Now

In re-factoring ModExec, I have started with the exceptions. I’m debating how I used to do them. When I first started I used Error qw/:try/ and Error::Simple for exceptions. I still think I will, it looks like it’s still being well-maintained by Shlomi Fish (see here). I think that the piece I will bite off first is to get some test coverage around my exceptions and add documentation. They’re not much more than what you get...

perlsphere.net perlsphere.net

Gist of the Day: Named Capture in Perl Regular Expressions (Briefly)

One of the largest critiques I see about regular expressions is that they lack readability. Well, in Perl 5.10 named capture was added (http://perldoc.perl.org/perlretut.html) which I think adds an awful lot of readability to Perl regular expressions. The Caveats I’m using UTF-8 in this demo. I am not going to go into all the details of working with UTF-8 since it isn’t the point of this gist. There are a number of ways to capture...

perlsphere.net perlsphere.net

Gist of the Day: Test::MockModule for Repeatable Tests!

I like repeatable tests. The #1 benefit of repeatable tests is that they’re repeatable. This also means they’re less vulnerable to data changes (e.g. this test depends on this product record remaining unchanged) and don’t pollute your environment. There are two ways that I think you can make your tests repeatable, and I think both of them are equally valid, and each should be used in their appropriate time: Creating and tearing...

perlsphere.net perlsphere.net

Gist of the Day: How to Test a File You Wrote!

First, I suppose I should apologize for two days of silence. I am currently going through a major life transition, so things could get a little spotty for a while. I haven’t forgotten about you. I actually have had a couple of days where my experiment for the Gist of the Day failed, and I couldn’t get something working in time to put it up. Today, however, I do have something for you! Today we are going to cover two topics very...

perlsphere.net perlsphere.net

Gist of the Day: Mojo Merging Hashes

Mojolicious is a fun module/framework/thing for me. How do I love Mojolicious? Let me count the ways (sorry Shakespeare): Mojo has ridiculously few dependencies, especially when compared to other web frameworks Mojo brings web servers (morbo and hypnotoad) with it Mojo does MVC, or doesn’t do MVC, whatever I want to do Mojo has templates, and they’re outstanding Mojo does routes very simply, which is badass I can write an entire...

perlsphere.net perlsphere.net

Gist of the Day: Using Mojo, Mongo, and SL4A to send SMS Messages (2 of 2)

I am very sorry that I missed posting this yesterday, I kinda got crazy sleepy and went to bed shortly after getting home from work. AS PROMISED, however, this next Gist is the SL4A Android component. This program gives you two buttons: “Process Queue” and “Exit the program!” With these two buttons you can either process a message from the queue (see previous post) or exit the program. Processing the queue involves sending an...

perlsphere.net perlsphere.net

Gist of the Day: Using Mojo, Mongo, and SL4A to send SMS Messages (1 of 2)

I got a little bored with what I had been posting (I suspect you did, too), so I’m doing something neat. I’m going to write a full (though limited) program for you. Here are the user stories (if you don’t know what user stories are, see here before continuing): As a web user I can enter a phone number and a SMS message into a queue so that it can be sent by a mobile handset. As a mobile handset user, I can push a button to...

perlsphere.net perlsphere.net

Gist of the Day: Find Which List Items Make Up a Given Sum

Here’s the scenario: you have two lists of integers, and you have a sum. Write an algorithm – in Perl, of course – to find which two items when summed give you a specified number. If no pairing exists, don’t return anything. If a pairing does exist, return the first pair you encounter. Remember, you could get two very large input lists. Brainstorming So when I first saw this problem, I wanted to do a nested loop. I really...

perlsphere.net perlsphere.net

Gist of the Day: Ends in Four

Sometimes we have a simple task to do and we over-think it. Such was the case when someone asked me an interview question one time. They said, write me a quick function to prove that a provided integer ends in the number four. Instantly, without really thinking about it, bit operations popped into my head. My first instinct was to use the comparison if (shift(@ARGV) & 0x04) and that was wrong. Lucky for me I caught it immediately,...

perlsphere.net perlsphere.net

Gist of the Day: Analyzing Performance with Benchmark.pm

In my post on Inline::C a few days ago I mentioned The Rules of Optimization Club, and then I ranted a little bit about how if you cannot measure a performance problem then you don’t have a performance problem. That’s not to say that you’re incorrect in asserting that you have a performance problem, it is only to say that you cannot identify any particular part of the problem as a performance problem until you have measured...

perlsphere.net perlsphere.net

Gist of the Day: Some convenience macros for use with Perl C internals

I feel awful. Like, really awful. The baby is sick, my partner is sick, I am sick. You still want something neat though, so I’m going to show you something very simple that I’ve used for a while. As I’m sure you noticed in yesterday’s Inline::C demo, Perl guts and C API are pretty noisy with a lot of boiler-plate. For this reason, when I first started playing with Perl guts and API, I created a header file just to make things a...

perlsphere.net perlsphere.net

Gist of the Day: Inline::C in Perl

I like Perl and I like C (most of the time), and sometimes I like to mix the two. The two main reasons I might want to mix the two is for performance, or because something is written in C which I would like to use from Perl. I’ve only really ever used C from Perl, I’ve never used Perl from C. Today’s demonstration is how to implement a simple binary search algorithm in C, but using Perl internals, and calling the algorithm from...