Perl 5 Porters Mailing List Summary: May 19th-24th

Hey everyone,

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

Perl 6 Hands-On Workshop: Weatherapp (Part 2)

Read this article on Perl6.Party

Be sure to read Part 1 of this workshop first.

Imagine writing 10,000 lines of code and then throwing it all away. Turns out when the client said "easy to use," they meant being able to access the app without a password, but you took it to mean a "smart" UI that figures out user's setup and stores it together with their account information. Ouch.

The last largish piece of code where I didn't bother writing design docs was 948 lines of code and documentation. That doesn't include a couple of supporting plugins and programs I wrote using it. I had to blow it all up and re-start from scratch. There weren't any picky clients involved. The client was me and in the first 10 seconds of using that code in a real program, I realized it sucked. Don't be like me.

Complicated joins with DBIx::Class

DBIx::Class is a great way to hide database interactions in your Perl classes. However, something that you might find easy in normal DBI queries can seem hard in DBIx::Class, because you lack direct access to the SQL. Take for example the following query:

select dayparts.name from eventtyperooms 
  join slots on (eventtyperooms.room_id=slots.room_id) 
  join dayparts on (slots.daypart_id = dayparts.id) 
  where slots.is_reserved=0 and eventtyperooms.eventtype_id='E375219C-CDBB-11E5-8739-AFC57843E904' 
  group by slots.daypart_id 
  order by dayparts.start_date asc;

There are lots of joins going on here and not all of them are on primary keys. Plus we’ve got some other qualifiers in there. This is where search_related() can come to the rescue.

$eventtype->search_related('eventtyperooms')
  ->search_related('slots', {'slots.is_reserved' => 0})
  ->search_related('daypart')
  ->search(undef, {
    group_by => 'slots.daypart_id', 
    order_by => 'daypart.start_date'
  });

The above code will generate the following query:

SELECT `daypart`.`id`, `daypart`.`name`, `daypart`.`is_locked`, `daypart`.`start_date`
  FROM `eventtyperooms` `me` 
  JOIN `slots` `slots` 
    ON `slots`.`room_id` = `me`.`room_id` 
  JOIN `dayparts` `daypart` 
    ON `daypart`.`id` = `slots`.`daypart_id` 
WHERE `me`.`eventtype_id` = 'E375219C-CDBB-11E5-8739-AFC57843E904' AND `slots`.`is_reserved` = '0' 
GROUP BY `slots`.`daypart_id` 
ORDER BY `daypart`.`start_date`

This allows you to use all the existing relationships you’ve set up in your schema to do complex joins.

[From my blog.]

Hiring in Sydney Australia

Staples is hiring Perl developers like crazy here in Sydney Australia.

I understand they are running a linux+perl+oracle environment, with the usual periphery of open source to boot.

More details and apply at: http://buff.ly/1TImJxp

There are a few other companies hiring too, check them out at https://www.facebook.com/sydneypm

(Disclaimer: I am not employed by Staples now or prior. I am just helping people pay their mortgages etc)

A Date with CPAN, Part 10: Cleanliness Is Next to Timeliness

[This is a post in my latest 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.

IMPORTANT NOTE!  When I provide you links to code on GitHub, I’m giving you links to particular commits.  This allows me to show you the code as it was at the time the blog post was written and insures that the code references will make sense in the context of this post.  Just be aware that the latest version of the code may be very different.]


Last time I rearranged our UI to be (hopefully) a bit more intuitive.  This time I want to clean up the remainder of those pesky CPAN Testers failures on our way to the next solid release.

FFI::Platypus is interesting. It seems like real FFI module for Perl 5.

FFI::Platypus is interesting. It seems like real FFI module for Perl 5.

FFI is foreign function interface. This is a little slow than XS, but you can call C/C++ library without C code.

I saw some FFI module for perl 5, FFI, or FFI::Raw, but not enough to create C extension flexibly.

FFI::Platypus seems like excelent module because you can call any C/C++ library using its features.

FFI::Platypus/CPAN

I try some example. All work well.

  use FFI::Platypus;
 
  my $ffi = FFI::Platypus->new;
  $ffi->lib(undef); # search libc

  # call dynamically
  $ffi->function( puts => ['string'] => 'int' )->call("hello world");

  # attach as a xsub and call (much faster)
  $ffi->attach( puts => ['string'] => 'int' );
  puts("hello world");

You can also create C structure in Perl code by using "record_layout" method.

Perl 6 Hands-On Workshop: Weatherapp (Part 1)

Read this article on Perl6.Party

Welcome to the Perl 6 Hands-On Workshop, or Perl 6 HOW, where instead of learning about a specific feature or technique of Perl 6, we'll be learning to build entire programs or modules.

Knowing a bunch of method calls won't make you a good programmer. In fact, actually writing the code of your program is not where you spend most of your time. There're requirements, design, documentation, tests, usability testing, maintenance, bug fixes, distribution of your code, and more.

This Workshop will cover those areas. But by no means should you accept what you learn as authoritative commandments, but rather as reasoned tips. It's up to you to think about them and decide whether to adopt them.

Project: "Weatherapp"

In this installment of Perl 6 HOW we'll learn how to build an application that talks to a Web service using its API (Application Programming Interface). The app will tell us weather at a location we provide. Sounds simple enough! Let's jump in!

Preparation

Virtual Spring Cleaning (part 10 of X) wherein I tackle finances

One of my tasks when I'm not working or writing Perl code is to keep the finances of the Frankfurt Perlmongers e.V. club in order. Part of this is doing the taxes but a more important part is to pay the incoming invoices in time and to keep all the receipts for this in order. As we do most transfers electronically, it was a long-term goal for me to provide the board with an automated monthly account statement.

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.