Movie file reader

Last night I finally got to see The Martian. It was a fun movie, and it seems much of the science was solid. One thing that filmmakers still like to do is have computers spit out messages one-character-at-a-time as if they were arriving like telegrams. If you would like to read a file like this, I present the movie-file-reader. First, my very long-hand version:

#!/usr/bin/env perl6

sub MAIN (Str $file) {
    for $file.IO.lines(:chomp(False)) -> $line {
        for $line.comb -> $letter {
            print $letter;
            my $pause = do given $letter {
                when /<[.!?]>/ { .50 }
                when /<[,;]>/  { .20 }
                default        { .05 }
            }
            sleep $pause;
        }
    }
}

How removing . from @INC is about to break CPAN

In Perl 5.26, it will no longer be a safe assumption to assume . is in @INC. This is a good move towards a more secure Perl, but will break the installation of many CPAN modules. For those of you wondering why this was done, see this post for more information.

Many CPAN modules try to do things like: use inc::Module::Install; This depends on . being in @INC. If you invoke Makefile.PL without it, the script will not even run.

We have come up with several ways to mitigate and ultimately fix the problem:

Short Term

Perl 5.26 will support an environment variable "PERL_USE_UNSAFE_INC=1". If you set this, any perl script invoked will include . at the end of @INC. Tentatively, support for this environment variable will be immediately deprecated since long term, the CPAN modules need to simply take this into account.

What happened to . in @INC

In Perl, module loads have always attempted to look for the module you refer to in the current working directory (not necessarily the script location). It has always been this way in Perl. This goes back to the keyword "do" which precedes "require". When this was originally coded, it was also common to include . in your PATH.

Convention changed somewhere in the 90's. It is now considered a bad practice to include . in your PATH. Most languages also do not attempt to look for . in @INC. During my research earlier this year, I found that of all of the scripted languages, only Ruby used to have . in @INC and it was since removed.

Perl used in an unusual place

Here's an article by New York City-based Perl hacker Jim Keenan on Medium.com about an unusual place where Perl has been put to good use:

https://medium.com/@jkeenan/perl-and-the-art-market-in-a-time-of-historical-turmoil-35a287171b6f#.yq627prvh

Barcelona Perl Workshop 2016 in 3 movements

So Barcelona Perl Workshop 2016 happened this 5th of November. This is my report in three movements.

I've been listening for quite a few time that we should blog about the events we attend and love. I know it's good for multiple reasons, and I think it's a good advice. I've helped organize, attended and talked at the workshop and I knew I wanted to write about it, but it took me a few days before even thinking on actually do it.

Staying on top of bitmaps

While putting off working on my Perl Advent Calendar submission, I was instead active in resolving bugs in App::ShaderToy and adding some interesting features. The three major features I added this week are, in order of implementation, loading of bitmap images, hot reloading of code and the feature to make the window stay always on top.

It is incredible how much joy quicker iterations bring me while toying around with shaders, tweaking the parameters to see if I can find new visuals.

David Farrell's berrybrew updated

berrybrew is the equivalent of Unix's perlbrew for Windows platforms, which uses Strawberry Perl portable instances.

With David's permission and blessing, I've merged the numerous updates and features I wrote into my berrybrew fork into his.

If you want or need his previous version, do a checkout of this commit (6bc28ae).

Many thanks go out to David for originally providing this software, and being polite and easy to deal with. I don't use Windows as my every-day platform, but when I do, this made it much more enjoyable.

Finding cheaters with k-mers

This semester I'm teaching Perl 6 to beginners. On a recent homework, student A came to see me for help, so I pretty much wrote the script (if you come for help, you get help!). With every assignment, I provide a "test.pl6" script that lets the students know if they will pass. I stress that they don't need to code for edge cases -- just look to pass the test suite. Well, two students, B and C, copied student A, changed a variable name, and submitted.

If I had only checked for passing tests, I wouldn't have noticed, but I like to see how different students try to solve the problems. I'm often pleasantly surprised as a couple of students have some programming background and try to really use the language's strengths. On this occasion, I was disappointed to find that student's B and C (who have little prior coding experience) had turned in my own code.

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.