Refactoring Very Old Perl 5 in Perl 6

Back when I was first learning Perl, I'd been doing Unix system administration for a couple years, and one command I ran a lot was this one:

ps auxww | grep something

(On some systems it was 'ps -ef'.) That would get a full listing of all running processes and grep them for "something." I soon got tired of typing all that, so I made a shell alias:

alias pst='ps auxww | grep '

Developing virtualhost-aware PSGI applications: Plack::Middleware::MockProxyFrontend

Let’s say you work on a team that runs a web content management system for various different customers. It is hosted at ourcms.com, but each customer’s public content is published on a different domain, which is determined by a setting in the interface, which they can change at will. When a customer is logged into ourcms.com they see links to their public content in various places, and some of the public content has “edit this”-type links back into ourcms.com. All of this runs as a single PSGI application. A not unfamiliar scenario, presumably.

How do you spin up a development server where you can test this?

Do something for CPAN Day 2015

CPAN Day marks the date of the first upload to CPAN, on 16th August 1995. Last year was the first time we celebrated CPAN Day, and many of us did a lot of different things. Why not do something helpful for CPAN on Sunday 16th August?

Fun with Catalyst and Heroku

For my first experiments with heroku I decided to adapt an existing Catalyst application…

Minor Issue with Perl 6 Install on CentOS 6

I had a little hiccup while installing Perl 6 on a CentOS system, and thought I'd leave the details here in case it happens to anyone else.

[Update: This has already been fixed by one of the Perl 6 devs, who isn't able to login here to comment. Panda installs without needing lsb_release. So my kludge is no longer needed.]

I used rakudobrew, and installed rakudo with moar just fine. But "rakudobrew build-panda" failed with "Unable to execute 'lsb_release -a 2> /dev/null'". That lsb_release program wasn't installed on this system, but yum said I could get it from the package redhat-lsb-core. Unfortunately, when I tried to install that, it came up with a list of dozens of dependencies to go with it, including a lot of X stuff like ghostscript and libGL, even some sound packages.

From Sydney PM "EVANGELIZING PERL"

Stuart Cooper gave a talk at this last month's Sydney PM meeting. His talk was "analog" in that he gave it without slides from hand written notes with the purpose of provoking a guided discussion. The outcome was rather successful with people offering thoughts and experiences, along with references to websites and books. It was very productive and enjoyable.

He typed up and published his notes on the Sydney.PM emai llist, which are posted below with hyperlinks added for reference.

EVANGELIZING PERL
Talk by Stuart Cooper for Sydney.pm meeting, July 2015

1) Perl advocacy?
Not advocacy - evangelism - spread the word.
In the early 1990s Linux had some powerful Evangelists;
Linus himself, Jon 'Maddog' Hall etc and even one of the
world's top supermodels - Linux Evangelista.

Your target audience for your evangelism is your Linux-using co-workers.
They might be Ruby guys, DevOps guys, sysadmins, Java programmers,
any group of intelligent Linux users.

P6SGI: Perl 6 Web Service Gateway Interface

So, I have been meaning to start a Perl 6 blog for a couple of months. At that point, though, this site was having issues and I have this perverse desire to write blog software every time I think about blogging and so things got put off for a bit. I am now starting this here and I want to get write off and start with what I think is my most important Perl 6 contribution thus far and one I want to get your feedback on: P6SGI!

For those that need instant gratification, here is a P6SGI application:

    # Perl 6
    sub app(%env) { 
        (200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World!' ]) 
    }

Job::Machine integration

Integrating Job::Machine into Djet.

Using Unicode in Emacs for Perl 6

I use vi/vim for quick edits and remote work, but I do most of my programming (and other work) in emacs. To enter Unicode characters in emacs, you run the "insert-char" command, which by default is tied to "C-x 8 [Enter]", then type in the hex code for the character or its name.

Typing at least 5 characters to get one got old very fast, now that there are some Unicode characters that can be used as Perl 6 operators. So I wrote a lisp function which asks for a single character and looks it up in an alist (kinda similar to a Perl hash). That way I can enter any Unicode character I've put in the alist by hitting two keys: one key to run the function, then whatever key I assigned to that character. Here's the lisp, which I put in my .emacs file:

Dancer2::Plugin::Auth::Extensible Presentation

Andrew Beverly is going to talk about https://metacpan.org/pod/Dancer2::Plugin::Auth::Extensible at the Perl Dancer Conference.

This talk will give an overview of what's now possible with very little code, including user registration, password resets and the management of user details.

CPAN PRC: July is Data::Dump

For July, the CPAN Pull Request Challenge assigned me Data::Dump. Better than the pull request itself, this assignment was great to know Data::Dump, as I have never see it before.

For the PR, I tried to read user complains, and one suggestion was to keep UTF-8 intact when dumping to a stream that is utf-8 aware. I created a basic PR, so illustrate a possible solution. Unfortunately, as on most of the previous months, I did not receive any feedback yet. But the pull request is there, ready for comments or to be merged.

Schedule for Swiss Perl Workshop 2015 ready

We are happy to announce the schedule for the Swiss Perl Workshop 2015.

We will have the Perl 6 Hackathon starting on Thursday August, 27th, Talks on Friday, August, 28th and Workshops and Talks on Saturday, 29th.

Since so many people are contributing to this years' program, it is difficult to highlight any events.

Feel free to listen to the talks you are interested in

  • War stories: programming in the field of medieval history‎‎
  • QA with Larry Wall‎
  • ‎Parallelism, Concurrency, and Asynchrony in Perl 6‎
  • ‎How to create CRUD database webapp in 40 minutes?‎
  • ‎Whatever, or How I Stopped Worrying and Fell in Love with Perl 6 Operators‎
  • ‎Normal Form Grapheme‎
  • ‎API Design‎
  • ‎Pearls from the contest‎
  • ‎OAuth2 and Mojolicious‎
  • ‎The Cool Subset of MAIN‎
  • Processing toki pona with Perl‎
  • ‎Introducing Replay
  • ‎Web::Machine - Simpl{e,y} HTTP‎
  • ‎Genetic Algorithms in Perl

or join the workshops

  • Kickstart your Perl 6 development
  • CallBackery Hands On‎
  • Perl 6 hands on
  • Hands-on code coverage tutorial

or come to meet us and do some socializing.

We have stil a place for you to join us, please register at perl-workshop.ch.

Simple Game in Perl 6

Here's a little game which was a sub-game in the 1980's Commodore 64 game Legend of Blacksilver. It's a simple gambling game where you are dealt five cards in a row from a standard 52-card deck. The cards are then turned up one at a time. After each card is turned up, you have to guess whether the next card will be higher or lower in rank than the last one. Aces are high, and you lose all ties. If you guess all four right, you win.

[Update: There's a serious bug in this version, as pointed out by Brad in the comments, but I'm leaving it in the original so the comments make sense, since I'm writing these for learning purposes. A fixed version can be found at my GitLab account.]

Perl5 to Java compiler is 1 month old, and we have a hackathon

We are having a hackathon at work, and Bosko, John and I have hacked together a working Perl script that executes in a Java environment (HBase).

Nóirín Plunkett

I'm sad to report that Nóirín Plunkett has passed away. Many in the Perl community knew them as a speaker and participant at YAPC::NA 2012 in Madison, Wisconsin, and YAPC::EU 2012 in Frankfurt, Germany, as well as other conferences including Open Source Bridge, OSCON, and ApacheConf.

Nóirín was passionate about open source, open documentation, and open community. In addition to their leadership within the Apache Software Foundation and the Ada Initiative, they were also a contributor to Perl v5.14. Most importantly, they were a friend and advocate to many in the open source and tech communities.

Making Alien::Base more reliable

The Alien::Base (AB) team has done a number of things over the past year with AB to make the installing packages more reliable. For AB based Alien developers who have created their own Alien::Libfoo this is great because they get the benefit of more reliable installs when users upgrade their version of AB without having to release a new version of Alien::Libfoo. Though largely backward compatible with version 0.005 (or perhaps further), modern versions of AB have also been given a few interface enhancements that require changes in Alien::Libfoo in order to benefit. So if you are an AB based Alien developer, please consider a couple of simple changes that you can make to make your distribution more reliable.

Use %c instead of %pconfigure.

Getting Started

I started programming in Perl in about 1995, a few years before design started on Perl 6. Over the years, I've taken a look at Perl 6 from time to time, but never got hooked. Sometimes it appeared too hard to get a working system running -- assuming you could at all. Other times the language looked so foreign that I wasn't sure what the point was: if it didn't even look like Perl, then it might as well be a different language, so why not go learn a different language that was ready?

Well, that finally changed this summer. The impetus was an interview with Larry Wall wherein, with his unique style, he talked about the language (and a variety of other things) in ways that intrigued me and made me want to see what he'd created. Hearing that a real release of Perl 6 was no more than several months away, and that a working compiler could be installed with a few commands, hooked me the rest of the way.

Masking Images with Imager

Sometimes you want to do something fancy with images in a completely automated way.  So for example, maybe you want to turn the image on the left into the image on the right:

image

It turns out this is a pretty simple process using Imager.

Step 1 - Create a blank image.

use Imager;
my $tile = Imager->new(xsize => 450, ysize => 450, channels => 4);

Step 2 - Create a mask. This is just a PNG file that is black where you want transparency, and white or transparent where you want things to show through. In my case I created this mask.

image

Step 3 - Use combine your mask with the image you want to mask.

my $mask = Imager->new(file => 'mask.png');
my $craftsman = Imager->new(file => ‘craftsman.png’);
$tile->compose(src => $craftsman, mask => $mask);

Step 4 - For extra flare, add a bevel. 

image

my $bevel = Imager->new(file => ‘bevel.png’);
$tile->compose(src => $bevel, opacity => 0.8);

Note: Technically, the bevel is being created in some extra software like Photoshop or Gimp, and we’re just applying it here.

Step 5 - Save the file.

$tile->write(file => ‘tile.png’);

image

As you can see, it’s pretty easy to do some pretty cool effects in Imager. Enjoy.

[From my blog.]

Perl::ToPerl6 released to CPAN

$ perlmogrify my-script.pl
$ more my-script.pl.pl6

Perl::ToPerl6 is now available on CPAN. This is the final name for the previously-mentioned Perl::Mogrify tool, with the goal of being able to transliterate (not translate, subtle distinction there) working Perl5 code into compilable Perl6.

Please ignore most of the documentation aside from the README file, as this application is heavily cribbed (read: mostly copied) from L (Thanks Jeffrey.) This tool is meant mostly for module authors, so please don't expect (yet!) a production-quality idiomatic Perl6 translation - We're still not sure what "idiomatic" Perl6 will look like.

Most of my effort has gone into changing operators because that's not easily done in search-and-replace (Keep in mind '.' -> '~', '=~' -> '~~', '->' -> '.') and whitespace is now significant in more places than you'd suspect based on a casual overview. Basically I'm trying to fix most of the simple stuff that would trip people up if they're porting modules by hand.

YAPC::EU - over 200 participants

YAPC::EU Granada has just passed 200 confirmed participants already passing two previous YAPC::EUs and there is still more than a month to go.

YAPC::NA in Salt Lake City gained more than 100 additional participants in the last 30 days, but they used a PR firm. I wonder if YAPC::EU will also get another 100 people. I try to log the numbers for future reference, but I am not sure how to help the organizers reaching more people.

The list of talks is certainly interesting and there are also the courses (and I hope my course will attract a number of people who would just want to learn AngularJS and as a side effect I can show them Perl as well.

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.