PPIX::Refactor

(Moved from reddit.com/r/perl now that blogs.perl.org seems to be behaving itself).

Over the past year or so I've had to deal with PPI for parsing and rewriting perl code a handful of times. Refactoring scripts are generally one-shot single purpose. Like any data mangling activity refactoring scripts can get messy because they're generally disposable, so architecture tends to be an afterthought at best. You can kind of tell this if you go and read Perl::Critic policies. They're plagued by boilerplate and repetitive code, and that's for code that is extensively reused. The problem multiplies in the case where you're writing throwaway code against PPI. In this post I'm going to show off PPIx::Refactor, which is a minimal interface to contain a small but annoying part of the mess.

Corrupting the Youth

There's a new version of Modern Perl out in print now. So, what should you do with your old one?

I gave mine away.

Programming Exercises for beginners

I have started to create a list of programming exercises. Mostly extracted from my Perl beginner course. Some of them already have "Tools" that help solve the exercise. Some of them even have links to a solution in Perl 5.
My plan is to add many more exercises and to provides "Tools" and "Solutions" in Perl 6 and other programming languages as well. (Currently Ruby, Python and JavaScript are on the short list.)

If you have ideas for exercises I'd be happy to hear about them.

Support PerlDancer.... get a book!

Do you use Dancer? Even if you don't, want to help one of the most awesome projects in the Perl community grow and reach a wider audience? You can, and you can get a copy of the book we're writing for helping us out.

It's simple: go to https://www.kickstarter.com/projects/1856511822/perldancer-book and help fund our project. Not only will you get credited for your contribution in the book, you get a copy of the book for backing us too!

Help the Dancer devs bring Dancer to a larger community, and help us get this book done. It will be a great resource for new and experienced developers alike.

Thanks in advance. We <3 you :)

Reminder: London Perl Workshops Call For Papers ending soon!

London Perl Workshop: http://act.yapc.eu/lpw2015/ on 12th of December.

I'm pleased to be sponsoring again this year as http://perl.careers/, but a reminder that the deadline for talks is end of this week, Friday the 6th of November!

If you'll just be attending but not speaking, by signing up early you'll make sure there's enough coffee and beer for you...

Perl 5 Porters Mailing List Summary: October 27th - November 1st

Hey everyone,

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

Net::SFTP::Foreign in taint mode

For October’s turn of the CPAN Pull Request Challenge, I was assigned Net::SFTP::Foreign. I concentrated on one of the latest issues reported: in recent Perl versions, the module didn’t work in taint mode.

Test::Stream: Have your cake and eat it too!

*** UPDATE ***

After this was written I received feedback from several respected members of the community alerting me to the problems that could be caused by is() *guessing* if it should be comparing numbers or strings. After hearing this feedback I agreed that the behavior constituted a bug, and one serious enough to alter the behavior post release. Test::Stream was marked *stable* recently enough that the change should not impact very many people, if in fact any.

The latest version of Test::Stream on CPAN no longer guesses if it is given a number vs a string.

In the very near future cmp_ok, and a 'Classic' bundle which provides just the functionality of Test::More, including classic 'is' and 'is_deeply' will be released, and will be the recommended bundle for people moving from Test::More. Branches and pull requests for both of these have been written, I am giving them some time for review before proceeding with their release.


List::Slice - Slice-like Operations for Lists

How many times have you needed to do this?

my @found_names = grep { /^[A-D]/ } @all_names;
my @topfive = @found_names[0..4];

Or worse, this.

my @topfive = ( grep { /^[A-D]/ } @all_names )[0..4];

There's got to be a better way!

Or this.

my @bottomfive = @names < 5 ? @names : @names[$#names-5..$#names];

Or this.

my @names
        = map { $_->[0] }
        sort { $a->[1] <=> $b->[1] }
        grep { $_->[1] > $now }
        map { [ $_->{name}, parse_date( $_->{birthday} ) ] }
        @all_users;
my @topfive = @names[0..4];

There's got to be a better way!

There's got to be a better way!

Now there is! Introducing: List::Slice!

A Date with CPAN, Part 3: Paving While Driving

[This is a post in a new, probably long-ass, series.  You may want to begin at the beginning.  I do not promise that the next post in the series will be next week.  Just that I will eventually finish it, someday.  Unless I get hit by a bus.]


Last time I went into more details about how I might go about creating a new date module, and what I would expect it to achieve.  This time we clear out some housekeeping and try to nail down a design strategy.

HTTP::Response may have a different definition of success than you do

The is_success() method which HTTP::Response provides is not necessarily a full indicator of success. This has bitten me before, so I thought it was worth writing about. Perhaps it may save you some heartache down the line.

Read the full post.

Test::Stream going stable

Test-Stream, the intended successor of Test-Simple (Test::Builder, Test::More), is moving out of the experimental phase. The experimental notice has been removed from all but a couple modules in the distribution. Now is a good time to start writing new testing tools using Test-Streams capabilities.

What does this mean for Test::More, Test::Builder or my existing test tools?
At the moment it means very little. Test::Builder is still around, and not going anywhere any time soon. At the moment Test::Builder based tools and Test::Stream based tools will not work together in a single test script, though they can both be used in different files in a single test suite.

Perl 5 Porters Mailing List Summary: October 20th-26th

Hey everyone,

Following is the p5p (Perl 5 Porters) mailing list summary for the past week (including Monday the 26th). Enjoy!

More Dancer2 goodness

Task::Dancer2 0.04 and Dancer2::Plugin::Queue 0.005 are on their way to CPAN. D22::P::Queue had test failures preventing it from installing. Task::Dancer2 re-enabled Queue in the bundle, and also the REST plugin.

Enjoy!

Outthentic - yet another test framework

Outthentic is a black box testing framework.

Instead of hack into objects and methods it deals with text appeared in stdout.

This is very first CPAN release to play with:


$ cpanm Outthentic

This is super fast intro:

A micro contribution to Perl

When you see an article on Reddit /r/perl upvote it. If you see an article about Perl that is not on Reddit yet, post it.

The Old Becomes New Again: A Gopher Server in Perl 6

The web is slow. Between overloaded pages, overloaded servers, bloated browsers, and ISP throttling, it's not unusual for even simple pages to take a couple seconds to load. But you get used to it, so I was struck by how fast the Internet can actually be when I fired up a gopher client recently.

Yes, gopher still exists, barely. For those who are unfamiliar with it, gopher is a sort of text-based hypertext system that predates the web -- think the web minus graphics, fonts, and interactive scripting, just files and directories and links between them, though you can also offer a few other things like search services. I miss those specialized services like gopher, IRC, and Usenet, that did one thing very well before they were overwhelmed by the web.

Dancer2 module updates now on CPAN

Last night Task::Dancer2 0.03 and Dancer2::Session::JSON 0.002 made their way to CPAN. Thanks to xdg and Yanick for their help with this. More updates to come in the following days.

Thank you to those who attended and sponsored the Perl Dancer Conference 2015 in Vienna this week! Looking forward to seeing you next year (sorry I had to miss this one).

Most importantly, thank you to the Dancer Core Team for extending an invite to me. I am proud to be one of you :)

Perl 5 Porters Mailing List Summary: October 12th-19th

Hey everyone,

I apologize for the delay. This summary should have been sent yesterday but I was busy at the Dancer Conference in Vienna.

Following is the p5p (Perl 5 Porters) mailing list summary for the past week (including yesterday and this morning). Enjoy!

6.concerns

My thoughts on the upcoming Christmas

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.