Moose Loose Ends Part the Seventh

Its very bad form day here in the Moose-pen

Today I wanted to clean up one thing on construction error handling namely getting the correct number of errors back on my 'AllErrors' object.

First a little house cleaning. The first thing I did today was create a new sub called '_new_misc_error'

Rakudo.js update - running Perl 6 in the browser with Parcel

Rakudo.js i n combination with parcel.js now supports running simple stuff in the browser. See https://github.com/perl6/perl6-parcel-example for an example of running a simple test.

It's not super usable and this moment and will likely explode if you try to have too much fun.
Hopefully this example will be replaced by something much more awesome soon.

Parcel.js is a web application bundler so it will take care of combining the JavaScript code Rakudo.js spits out with everything else your app needs to run.

Why Parcel.js instead of Webpack?
Mostly because Parcel while seemingly more buggy doesn't insist that hard on re-parsing the generated code.
I had a webpack plugin working for NQP at some point so it definitely is doable so webpack afficionados are welcome to contribute a plugin or entice me to write one.

Currently I'm using some cutting edge JS features (like BigInt) so I'm focusing on supporting Chrome.
I plan to spend some time on supporting other common browsers when Rakudo.js is more mature but luckily the evergreen browsers are constantly updating themselves and implementing new stuff so hopefully the problem will solve itself.

Dist::Zilla Starter revision 3 - Git, versioning, and more

I've just released revision 3 of the @Starter plugin bundle for the Dist::Zilla CPAN distribution authoring tool. There's no changes to the base configuration from revision 2, but there are now additional options to help manage common authoring tasks using modern best practices. You must set your revision to 3 to enable these new options, as a safety measure to make sure you have a new enough version of the bundle to support them.

Sydney Perl Tomorrow! (2018-09-25)

Please join us for September meeting of Sydney Perl Mongers.

This meet is hosted by Broadbean, who are providing the venue and catering.

Time: 6-9pm (roughly)
Date: Tuesday, 25th of September 2018
Location: 9 Hunter Street, Sydney

(Meet in the ground level foyer or just outside and be brought up)

We have two speakers, one on Dancer and either a repeat of my Perl in OpenWRT talk or a fresh talk on doing REST in perl6.

Find this event on Meetup dot com: https://www.meetup.com/sydney-perl/events/253778201/


Please join us on Facebook: https://www.facebook.com/sydneypm
Meetup dot com: https://www.meetup.com/sydney-perl/
Or website: http://perl.sydney/

Moose Loose Ends Part the Sixth

Its dig deep an play day here in the Moose-Pen

I my last post I figured out how to set up Database:Accessor to get the 'MooseX::Constructor::AllErrors' object in the 'around BUILDARGS' and then play with it, without breaking my existing code.

Today I want to see if I can change my error messages. I started by poking about in guts of ' MooseX::Constructor::AllErrors' and I discovered the the error messages are rather had coded;

sub message {
    my $self = shift;
    return sprintf 'Attribute (%s) is required',
        $self->attribute->name;
}
 
Now that does not do me much good as I can't just do this in my 'around' sub

The way to create Class with only Perl core language.

Do you know that Perl have enough object-oriented features in core language?

Not necessarily you need to use CPAN module to do object-oriented programing.

I write the entry "The way to create Class with only Perl core language".

The way to create Class with only Perl core features

package Point;

sub new {
   my $class = shift;

  my $self = {
    x => 0,
    y => 0,
    @_,
  };
  
   bless $self, $class;

  return $self;
}

sub x { shift->{x} }
sub y { shift->{y} }

 

my $point = Point->new(x => 1, y => 2);

my $x = $point->x;
my $y = $point->y;

In fact, which do you need

1. simple object-oriented programing

or

2. advanced object-oriented programing

in your job?

Installing sets of modules

In order to quickly install a set of Perl modules for a given task, it is nice to have some kind of meta-package serving no other purpose than pulling in a set of other more specific packages. Traditional ways of doing this with CPAN can be found in the Bundle:: and Task:: namespaces. Recent developments, however, seem to have put meta-package maintainers in a predicament. Technologies are shifting once more. In this article, I explain how I rescued my meta-packages with minimal changes.

Perl6::Math::Matrix (Part 3: when to use MMD)

In this guide about what to consider when writing a Perl 6 module, we (after part I and part II) will reach Perl 6's great power of signatures. They enable a feature, that is very often used in Perl 6 (internally and externally). Here are my arguments when the usage of MMD makes the most sense.

Moose Loose Ends V

Still make errors pretty day here in the Moose-Pen. Yesterday I re-discovered that I had 'MooseX::Constructor::AllErrors' set up in my code. I was even using it to test fail conditions like this test;

LOGOesque extension to Language::SIMPLE - Feature creep diverts attention.

In an attempt to standardise vector graphical operations in GUIDeFATE (the world's simplest GUI designer) across different back-ends and keep things simple, a little diversion was needed. For a standard vector drawing one might use the computationally cumbersome SVG format directly and draw that on the widget. The problem is that one needs to be able to manipulate the graphics easily and AFTER deployment. I needed to script the creation of the drawing. Now lots of applications use a script language of their own, e.g. gnuplot, matlab, Kalgebra, R etc, so clearly this is a useful functionality on its own. What would be also useful is a portable scripting platform. This platform could serve my purpose, but being modular, could be easily repurposed for other applications.

Image::PNG::Libpng now on Strawberry Perl

I recently received a bug report about installing Image::PNG::Libpng on Strawberry Perl. It was failing to install due to using the wrong C compiler.

Up to version 0.44 of the module, I'd been checking for the presence of libpng using Devel::CheckLib, however somehow or another that didn't seem to be working and I'd gone back to using my own module to detect the library.

Although this improvised detecting module was getting its information about the compiler flags and library flags from Config, I'd omitted to use the information about what the C compiler might be. Once I changed my module to get its information on the C compiler from $Config::Config{cc}, it worked on Strawberry Perl too.

So now you can use Lego::FromPNG, FuseBead::FromPNG, and some other modules on Strawberry Perl.

SQL::Translator::Parser::OpenAPI - generate a relational database from an OpenAPI schema

Version 0.04 of SQL::Translator::Parser::OpenAPI has just been uploaded to CPAN. You can give it an OpenAPI 2 spec and it will generate a relational database from it. How is that useful?

Normally when you want to make an information service, you'll start by manually making a database, or writing the API code, possibly writing tests along the way, and then writing an OpenAPI spec after that - see this excellent article by Jan Henning Thorsen for more on using OpenAPI with Perl.

With this module, you can start by writing a spec, and letting code generate a lot of the infrastructure. This has a number of advantages:

  • it's quicker
  • it's easier
  • it's more reliable - let solved problems stay solved rather than reinvent the wheel!
  • it lets you keep an eye on the big picture

The distribution uses for its tests, as well as one that tests that many-to-many relationships are correctly generated, a couple of specs written by others:

Moose Loose Ends Part the Fourth

Still error day here in the Moose-Pen

One thing I wanted to try and do was have a little more meaning in my error-messages much like I did yesterday when my error message put out something like this

Database::Accessor create( $db 'Class', $container 'Hash-Ref||Class||Array-Ref of [Hash-ref||Class]', $options 'Hash-Ref'); Error: Incorrect Usage:  The $container 'Array-Ref' must contain only Hash-refs or Classes. $container=$VAR1 = [
          1,
          {
            'last_name' => 1
          },
          bless( {
                   'first_name' => 'test',
                   'last_name' => 'test'
                 }, 'Data::Test' )
…

Perl6::Math::Matrix (Part 2: Converter)

In this series of articles I reflect and expand on a talk I gave this year in Glasgow were I spoke about writing Perl 6 modules in general and Math::Matrix in particular. Part I was about data types I used or wanted to use, because my approach is it to think first about data structures and built later the code around that. It is also crucial because this module basically provides the user a new data type.

How to install Perl Net::RawIP module on Windows Server

Hi Sergey,all
I trying to install perl Net::RawIP module on Windows Server 2012 R2 without success :-(
I also installed latest perl version for windows machine (5.28.0).

Could you help me?

Thanks and regards,
Marco Rottino
mrottino@gmail.com

Behind The Desk - Running The RPerl Booth at YAPC Europe AKA TPC Glasgow 2018

I came to my first ever Perl Conference to run a booth, which is quite the intimidating task, as I am but a humble Perl newbie.

I was representing RPerl, Will Braswell's Perl 5 compiler, and did my best to try and explain its purpose to the intrigued visitors. In case you missed the booth, I'll do a quick recap. RPerl can do two things: first, it can optimize the speed of normal Perl 5 apps to over 400 times in some tests; and second, RPerl can protect the intellectual property and source code of your software.

Between the conference days, I helped Will set up a Linux VM that would run a live demo of the compiler, and we were able to show it on the last day. This live RPerl demo included physics simulation algorithms running in both slow interpreted mode and fast compiled mode.

39501233_463740027436473_8967423377929142272_n.jpg
The conference was a great opportunity to meet several prominent members of the international Perl community, such as Mark Keating, Wendy Van Dijk, Jeff Goff, etc. I enjoyed my first experience at The Perl Conference, and I look forward to more in the future!

Moose Loose Ends Part the Third

Its pull hair day here in the Moose-Pen

Yesterday I merrily finished off all the changes where I swapped out die for confess and the changes where I updated the error messages to the same standard. I then happily check in Accessor.pm and was looking forward to a quick testing post for today. happily finished and checked the lot in. Then tried to run my test suite an got;

t/00_load.t ................. 1/1
#   Failed test 'use Database::Accessor;'
#   at t/00_load.t line 7.
#     Tried to use 'Database::Accessor'.
#     Error:  syntax error at /home/scolesj/database-accessor/lib/Database/Accessor.pm line 627, near "if"
# syntax error at /home/scolesj/database-accessor/lib/Database/Accessor.pm line 718, near "if"
opps obviously I did not run any tests before I checked in and pushed my code to github.

Perl Event Roppongi.pm #1 at 2018/9/14

Perl Event Roppongi.pm is opened at #1 2018/9/14

I get some pictures.

See all pictures Roppongi.pm Pictures

New class in Berlin...this Friday

Further information on my German speaking tour...

In addition to the talk I will be giving this Thursday evening, we will now also offer a free full-day training class in Berlin.

Specifically, we will be running my popular Technical Presentation class from 9:30 to 17:00 at Helmholtzstraße 2-9, 10587 Berlin.

As we can only accommodate at most 30 participants, we've set up a page on MeetUp, where you can register to attend. If you don't have a MeetUp presence, the MeetUp page has instructions for emailing the organizers directly so you can have your name added to the attendance list. Note that, although the MeetUp page is mostly in German, the class will be entirely in English. :-)

Thanks again to Frankfurt Perl Mongers, who are sponsoring my entire tour, to Berlin Perl Mongers, who are the local organizers, and to Strato AG, who are helping with the organization and also providing the training venue.

Stripping diacritics from input

If you have input containing lots of Unicode diacritics, and you need to process them into equivalent ASCII characters, there are several options on CPAN. My module Unicode::Diacritic::Strip offers a slow and reliable method involving the use of Unicode::UCD, and a fast method involving a tr/// operator.

Today I was examining user logs for a web application, and I noticed that the fast method had completely failed on input "Jalālu'd Dīn Muḥammad Rūmī" because it had failed to catch the middle h character. Looking at the Unicode characters I found a whole block of Latin characters which I'd omitted. I've now added them to the application for version 0.11

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.