Moose Delegates

Today in the Moose-Pen I am going to look at something new 'Native Delegations' on attributes or to say it another less wordy way 'Traits'

Native Delegation is a way to let you treat standard Perl data structure as if they where objects. So to take an example from my test cases say you have this

foreach my $index2  (0..(scalar(@{$predicates[$index]->predicates()})-1)) {
that (scalar(@{$predicates[$index]->predicates()})-1)) is not very readable. Now suppose we could just have this

($predicates [$index]->predicates()->count-1)

quepadre


i'm using padre editor with strawberry perl bundled in
dwimperl

i have multiple files open, then when i click on one of the
tabs to close 1 file, padre crashes without an error message,
the application just closes.
this also happens when i save the session.
kinda frustrating.
do you discuss padre here or am i in the wrong forum?
thank a bunch in advance

Perl 6 Core Hacking: Where's Da Sauce, Boss?

Read this article on Perl6.Party

Imagine you were playing with Perl 6 and you came across a buglet or you were having some fun with the Perl 6 bug queue—you'd like to debug a particular core subroutine or method, so where's the source for it at?

Asked such a question, you might be told it's in Rakudo compiler's GitHub repository. Depending on how deep down the rabbit hole you wish to go, you may also stop by NQP's repo, which is a subset of Perl 6 that's used in Rakudo, or the MoarVM's repo, which is the leading virtual machine Perl 6 runs on.

The answer is fine, but we can do better. We'd like to know exactly where da sauce is.

Stick to The Basics

The most obvious way is to just use grep command in the source repository. The code is likely in src/ directory, or src/core more specifically.

We'll use a regex that catches sub, method, and multi keywords. For example, here's our search for path sub or method:

Perl's Pegex Module: a great way to parse files by creating grammars

We recently came across Pegex and found it to be an interesting module for parsing text data. Instead of using regular expressions directly, the user can write a grammar for the data to be parsed. The data can be automatically converted to a native Perl object or, if the user desires, it's possible to use actions to handle the grammar while parsing using a Pegex::Receiver class.

Pegex uses the type of grammars called Parsing Expression Grammars (PEG), which is an unambiguous form of writing a grammar. Each parsed string will in effect have a single valid parse tree. Since Pegex converts the rules of the grammar to regular expressions, it is a greedy parser.

In this blog post we demonstrate how to easily use Pegex to parse an /etc/hosts file on Linux and convert the result into Perl objects automatically without having to manually create any object.

For more details check out the original blog post by me here.

Little Moose Tries to Run

Well more testing and re-factoring with just a little Moose in the Moose-Pen today. So I spend a good deal of time getting my tests cases all in a row. Now just a few interesting details on that, I created a number of generic utility tests that can be reused in my test cases. What I did was take the 'cmp_deeply' test like this on in 33_constants.t

Hello Dzone

Since the Perl Magazine sadly had to close i didn't wrote as many Perl articles anymore. Because I miss it sometimes I recently agreed to write for DZone. Its a Java- centric site with many light weight pieces. I read it myself, since you can find interesting stuff here and there.

But why I'm writing this here? In order to publish, it has to be transported from your blog. And since I don't own another blog and the Perl 6, Perl 5 and software engineering stuff I want to write about fits here nicely : I will use this blog as transport. for that purpose. So please don't wonder if some of my next text are here sound like I assume you never heard about Perl. If the entry is marked with the category DZone you know why.

But there is also another reason why I use this Blog. Since I will be a kind of press secretary for Perl in that area, I actually want to be controlled and corrected by you and also encourage you to engage in the discussions below these articles on DZone (link will be provided in comments), to make Perl more visible to outside world.

peace

All Good Things

Yesterday I announced the end of The Lacuna Expanse, the first massively multiplayer Perl-based web game. 

Perl 5 Porters Mailing List Summary: July 27th-31st

Hey everyone,

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

Relax it is Just Moose

Well it clean-up and re-factor day in the Moose-pen. So no new Moose Majick today just cleaning up and adding in stuff that I have left out (forgotten actually) and moving things about.

Well the first thing I did was finish off the last three of my remaining Accessor attibutes, 'gathers', 'filters' and 'sort' or if you are SQL inclined 'group by', 'having'. and 'sorts'.

The 'gathers' and 'sorts' attributes are just a pair of 'ArrayRefofElements' which I covered off in this post and types and the 'filters' is a 'ArrayRefofConditions' which I covered in this post. I did of course spend a little time making sure that my DAD role attributes matched up with the accessosr ones and as this is me programming I created two new test cases, 37_gathers.t that handles filters as well, and 39_sorts.t

Hacking on The Rakudo Perl 6 Compiler: Mix Your Fix

Read this article on Perl6.Party

While testing a fix for one of the Less Than Awesome behaviours in standalone Signature objects, I came across a bugglet. Smartmatching two Signatures throws, while spilling a bit of the guts:

<Zoffix> m: my $m = method ($a: $b) { }; say $m.signature ~~ :($a, $b);
<camelia> rakudo-moar 46838d: OUTPUT«Method 'type' not found for invocant of class 'Any'␤ in block at line 1␤␤»

So I figured I'll write about fixing it, 'cause hacking on internals is lots of fun. Let's roll!

Golf It Down

The less code there is to reproduces the bug, the fewer places there are for that bug to hide. We have a detached method and then we smartmatch its signature against something else. Let's try to golf it down a bit and smartmatch two Signatures, without involving a method:

<Zoffix> m: :($a, $b) ~~ :($a, $b);
<camelia> rakudo-moar 46838d: ( no output )

Comparing Perl, Python and Ruby's testing ecosystems, part 2

I've released the second part of my series comparing Perl, Python and Ruby's testing ecosystems, on my testing-focussed blog

August Perl Meeting (Sydney)

Please join us on Wednesday, August 17, 2016 from 6:30pm at Fishburners (608 Harris Street, Sydney, NSW)

Speakers are still being selected, please let us know if you would like to present a talk or lightning talk.

Join us on:

Low Stress Moose

So today in the Moose-pen I am going to move onto something a little differtn and that is my Accessor 'links' attribute which I am going to cover with the 35_links.t test suite.

I did a quick review of the bits and pieces I had stubbed in so far and I notices I need a few thing. First had a look at my Accessor 'links' attribute and I will need a new type for that. So to get this new 'ArrayRefofLinks' type I just did what we have seen in a number of older posts, namely add in a 'use', a 'class_type' and a 'subtype' into my Types.pm, I will hold off on a coercion for now till I get a little deeper into my post. So that takes case of 'links'.

I also noticed that 'Links' attribute of my DAD now had the wrong type as well so that was change to the 'ArrayRefofLinks' type

Looking at my 'Database::Accessor::Link' class I have never liked this two attributes

Perl 5 Porters Mailing List Summary: July 23rd-26th

Hey everyone,

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

Alpine Perl Workshop 2016 - Cfp extended - Keynote speaker wanted


logo.png

Not able to manage it to get to YAPC?
or
You are going to YAPC and you need more Perl talks?

Come to Alpine Perl Workshop, come to Innsbruck.

Consider to submit a talk.

Call for papers is extended till Sunday, August 21.

Sparrowdo automation. Part 4. Managing users and groups.

Hi! These are the previous articles:

This one is going to be quite short. We will learn how to manage linux users and groups using sparrowdo.

Let's get back to our ubiquitous example of installing CPAN modules:

task_run  %(
  task => 'install 2 modules',
  plugin => 'cpan-package',
  parameters => %( 
    list => 'CGI DBI'
  ),
);   

If we run this one we will see that CGI and DBI CPAN modules get installed into system paths, which is ok.

Consider a following case though:

Sophisticated Moose

Today in the Moose-pen I am going to play with the very familiar 33_condtions.t and this time I am going to solve another little API problem I know I am going to run into.

Part of my evil plan is to allow end users to add in conditions on the fly and I have made provision for that with the 'rw' 'conditions' attribute found on my DAD Role. Now I have to fix a minor oversight on my part can change the type on 'conditions' to be the same as the original in Accessors, so I changed this

–    isa     => 'ArrayRefofPredicates',
++    isa     => 'ArrayRefofConditions',
 
What I want to be able to do is allow my end users to do something like this

IRC::Client: Perl 6 Multi-Server IRC (or Awesome Async Interfaces with Perl 6)

Read this article on Perl6.Party

I wrote my first Perl 6 program—a New Years IRC Party bot—around Christmas, 2015. The work included releasing the IRC::Client module, and given my virginity with the language and blood alcohol level appropriate for the Holiday Season, the module ended up sufficiently craptastic.

Recently, I needed a tool for some Perl 6 bug queue work, so I decided to lock myself up for a weekend and re-design and re-write the module from scratch. Multiple people bugged me to do so over the past months, so I figured I'd also write a tutorial for how to use the module—as an apology for being a master procrastinator. And should IRC be of no interest to you, I hope the tutorial will prove useful as a general example of async, non-blocking interfaces in Perl 6.

The Basics

Comparing Perl, Python, and Ruby's test assertions

I've started a new series on my testing blog about the differences between Perl, Python, and Ruby's testing ecosystems and architectures. First article looking at the most basic assertions is done:

http://www.writemoretests.com/2016/07/perl-python-and-ruby-the-anatomy-of-a-testing-assertion.html

Perl 5 Porters Mailing List Summary: July 13th-22nd

Hey everyone,

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

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.