Oh column, where art thou?

When ramiroencinas added FileSystem::Capacity::VolumesInfo to Perl 6 ecosystem I've spotted that it has no macOS support. And while trying to contribute to this module I've discovered how less known Perl 6 features can save the day. What FileSystem::Capacity::VolumesInfo module does is parsing output from df command, which looks like this:

$ df -k -P
Filesystem                                  1024-blocks       Used Available Capacity  Mounted on
/dev/disk3                                   1219749248  341555644 877937604    29%    /
devfs                                               343        343         0   100%    /dev
/dev/disk1s4                                  133638140  101950628  31687512    77%    /Volumes/Untitled
map -hosts                                            0          0         0   100%    /net
map auto_home                                         0          0         0   100%    /home
map -fstab                                            0          0         0   100%    /Network/Servers
//Pawel%20Pabian@biala-skrzynka.local./Data  1951417392 1837064992 114352400    95%    /Volumes/Data
/dev/disk5s2                                 1951081480 1836761848 114319632    95%    /Volumes/Time Machine Backups
bbkr@localhost:/Users/bbkr/foo 123           1219749248  341555644 877937604    29%    /Volumes/osxfuse

(if you see wrapped or trimmed output check raw one here)

And while this looks nice for humans, it is tough task for parser.

TPF at OSCON London

Update: OSCON have supplied us with a discount code for unlimited free Pavillon Plus passes to members of Perl related organisations and the broader community. Just use the code: FREEORG. Use this code when registering for the Pavillion Plus pass and it will zero out the balance. You can register at: http://conferences.oreilly.com/oscon/open-source-eu/public/content/pavilion-pass - thanks to OSCON and O'Reilly for providing this.

This year OSCON, Europe, will be held in London between the 17th-18th October (with a training day on the 19th), the Perl Foundation will once again have a table in the not-for-profit pavilion. As at previous events volunteers will be manning the Perl stand throughout the day on the Monday and Tuesday and they will also be available in the early evening.

CPAN Tutorials

Almost a year ago, I wrote CPAN tutorials. It isn't an original work, it's a derivative of RubyGems Guides, only "translated" to Perl world. I failed to publish it anywhere until now. I'll be happy if anyone finds it useful in any way which the license allows. And I'll be even happier if I get any feedback.

And here it is: http://tynovsky.github.io/cpan-tutorials/

FASTQ to FASTQ with Perl 6

#!/usr/bin/env perl6

sub MAIN (:$out-dir="", *@fastq) {
    if ($out-dir.chars > 0 && ! $out-dir.IO.d) {
        mkdir $out-dir;

    my $i = 0;
    for @fastq -> $fastq {
        (my $basename = $fastq.IO.basename) ~~ s/\.\w*?$//;
        my $out-file = $*SPEC.catfile(
            $out-dir || $fastq.IO.dirname, $basename ~ '.fa');
        printf "%3d: %s -> %s\n",
            ++$i, $fastq.IO.basename, $out-file;
        my $out-fh   = open $out-file, :w;

        for $fastq.IO.lines -> $header, $seq, $break, $qual {
            # skip first "@"
            $out-fh.print('>' ~ $header.substr(1) ~ "\n");

    put "Done.";

The FASTQ format is one of the worst conceived in the history of bioinformatics, and that's saying something. The only sane FASTQ format uses 4 lines per sequence: a header starting with an "@" sign, the sequence, the header repeated but starting with a "+" (or just the "+"), and the quality score (in either phred 33 or 40). Here's a sample:

@HWI-ST885:65:C07WUACXX:7:2302:1866:196007 1:N:0:GCCAAT

What I thought would be fun to show off here is that you can read the contents of a list into more than one variable. Here I'd like to read four lines at a time, so I just read "lines" into four variables. How simple!

Cleaning up the IDs in a FASTA file

I have some FASTA files with headers like this:

>gi|83274083|ref|AC_000032.1| Mus musculus strain mixed chromosome 10, alternate assembly Mm_Celera, whole genome shotgun sequence

I wanted to extract just the 2nd field, so here's a Perl 6 script to do that:

#!/usr/bin/env perl6

use File::Temp;

sub MAIN (*@files) {
    my $i = 0;
    for @files -> $file {
        my ($tmpfile, $tmpfh) = tempfile();
        printf "%3d: %s\n", ++$i, $file.IO.basename;
        for $file.IO.lines -> $line {
            if $line.substr(0,1) eq '>' {
                my @flds = $line.split('|');
                $tmpfh.print(">" ~ @flds[1] ~ "\n");
            else {

        move $tmpfile, $file;

put "Done.";

Virtual Spring Cleaning (part 11 of XX) - in which I determine the type of yak wool I need

In what is a somewhat mild case of yak-shaving, I need a portable way of identifying file types in several situations. For example, when indexing files for Dancer::SearchApp or when handling user uploads, I want to somewhat reliably identify various files. I want to determine their type without trusting what the user tells me they are, and I also want to send the appropriate Content-Type header when serving files again.

The 2016 P5P Hackathon

It is a pleasure to announce that this year the Perl5 Porters Hackathon (http://p5h.org/), held between the 11th to 14th November in Amsterdam, will be hosted by Booking.com and officially supported by The Perl Foundation.

The P5P Hackathon is a seeding event for the essential work done inside the Perl core. It functions as a symposium where current, and future, Perl5 hackers can meet and cross-pollinate ideas that may develop into significant future evolution.

This year the Hackathon has three major aims:

  • The sharing of knowledge. This will be facilitated by talks of up to twenty minutes to share information about any field with which the speaker is intimate.
  • To facilitate open discussion. Free participation in conversations regarding important topics you or someone else suggests.
  • Hacking the Code: Working on specific problems in order to reach tangible results.

The Hackathon will take place within two different locations in Amsterdam at Booking.com offices, both locations are within a short walk of each other.

Short presentation of The new Perl debugger

The link of the project

You may Download presentation or view short video

The main feature of new debugger is debugging debugger commands. Yes you may debug itself (reentrance is not limited). This mean you may extend debugger easily. That is possible because of state of each debugger "copy" is saved in special array accessible through $DB::state

To enable debugger debugging (dd) you turn on this state then run command, you want to debug, after that. Example how to enable debugging debugger command 'step over' (n):

DB::state( 'dd', 1 );

Besides new debugger you get the new method to debug scripts and may forget about debugging by 'print' statements.

Now you just put special comment: #DBG: EXPR #

my $x =  { a =>  7 };

for( 1 .. 3 ) {
  #DBG:iter $_ #
  $x->{ a }++;

#DBG: e $x #

and get extended output while running script under debugger like this:

$ perl -d:DebugHooks::KillPrint            t.pl

{ a => 10 }

You may also limit output by writing the name of expression you are interested in:

$ perl -d:DebugHooks::KillPrint=iter       t.pl


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.