About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.
My habit for the past decade or so, back when I started learning Ruby, is to use irb (the interactive Ruby shell) as a calculator. I guess one can also use python, but irb was the one that stuck in my muscle memory. perl does have the interactive debugger perl -dee since forever, but by default it does not print the result of expressions. I am recently trying to change that habit though and use Reply instead. It's nice, with colors and all (especially with the DataDumpColor plugin).
Sometimes though, instead of numeric arithmetics or string operations, I want to do some date calculations. For example, what is the date (and day of week) 20 days from today? What's 2013-09-01 plus 40 weeks?And so on. Having to write a short script e.g. loading DateTime and creating DateTime object and all that seem so cumbersome.
Well, that looks interesting, except that what interested me wasn't the job, it was the information the ID tells us about weworkremotely.com/ (though I suspect it's not something they're worried about).
Marpa::XS, Marpa::PP, and Marpa::HTML are obsolete versions of
Marpa, which I have been keeping on CPAN for the convenience of legacy
users.
All new users should look only at
Marpa::R2.
I plan to delete the obsolete releases from CPAN soon.
For legacy users who need copies, they will still be available on backPAN.
About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.
Frankly, I was a bit surprised when searching for an existing CPAN module for this task and found none. There is DBIx::Compare, but it is for database contents and not structure (it can compare two tables' field names though). Hence DBIx::Diff::Struct. An example:
We warmly welcome you to join our Nordic Perl Workshop in Helsinki! The event will be held on Monday 17th of November 2014 at a seaside location where you can also enjoy the warmth of sauna and outside jacuzzi at the end of the day! We will also have pre-workshop events on the 16th, such as a hackathon and a pub crawl. Follow the program on the event site, we will add more information as we get all details sorted out.
Now you have the chance to have your say on the topics we will cover in the event. If you have some suggestions regarding the speeches please let us know.
The event will be epic, but we only have a limited amount of seats, so be sure to sign up now!
Unfortunately not many people host the code any more, and almost no one from those who might benefit from promoting their stuff there have ever sent me requests to include theirs ads. Therefore I am going to shut down the Perl Community Adserver which was hosted at two URLs: adserver.szabgab.com and pcas.szabgab.com.
I went over the logfile and sent e-mail to every person I could identify who still has the code on their web site.
If you have ever included the adserver on your pages and I have not sent you an e-mail, then please take this as my gratitude that you did host it. I think it served the Perl community a bit.
As I am going to shut it down soon, please, remove the embedded JavaScript from your pages.
Posting on blogs.perl.org brought new faces to our last Sydney PM, so heres details on our next event. Please join us if you are in Sydney Australia!
Hi All
Catalyst IT have offered to host us this month, so I went ahead and booked their board room. Thanks to Andrew Boag for setting the wheels in motion.
What: Sydney Perl Mongers Date: Tuesday, 11th November 2014 Time: 6-9:30pm Where: Catalyst IT, Suite 501-504, 89 York St Sydney NSW
The building locks it's doors at 6pm, so one of their staff will let us in. The same as SiteSuite and others. A contact mobile number will be posted later on for stragglers.
I will give a talk on HTML::FormFu.
We also need you to give a talk!
Catalyst IT will hopefully give us a talk on how Perl is used in their company to provide value to their clients. I understand they do a lot with the Koha library mangement software.
About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.
Any Unix user probably knows about the uniq command, most often used in combination with sort. For example, to get distinct lines from a file:
% sort somefile.txt | uniq
sort is usually needed because uniq can only skip non-unique adjacent lines. In other words, it does not keep a memory of past lines. This probably has to do with most traditional Unix utilities created in a decade where memory was very scarce (think of an age where the saying "640K ought to be enough for everybody" was considered a truism).
If you want to print distinct lines from a file but keeping the original order, it is surprisingly cumbersome to do using standard Unix utilities. That's why I wrote nauniq (distributed in App-nauniq). With this utility, you can simply do:
In many contexts, programs need to identify
non-overlapping pieces of a text.
One very direct way to do this
is to use a pair of delimiters.
One delimiter of the pair marks the start
and the other marks the end.
Delimiters can take many forms:
Quote marks, parentheses, curly braces, square brackets,
XML tags, and HTML tags
are all delimiters in this sense.
Mismatching delimiters is easy to do.
Traditional parsers are often poor at reporting these errors:
hopeless after the first mismatch,
and for that matter none too precise about the first one.
This post outlines a scaleable method for the accurate
reporting of mismatched delimiters.
I will illustrate the method with a simple
but useable tool --
a utility which reports mismatched brackets.
I took some time today to prepare a number of pull requests by MOREGAN for release, and the tarball for 1.219_001 is now on CPAN. Please test it and let me know if you run into problems with your module. Most of the changes simply improve parsing, but the ->prototype changes might break things if you relied on the previously broken behavior.
If no problems crop up, this will be released as 1.220 on tuesday, 2014-11-11.
I am not picky about which way it is sent to me, but feedback is best provided here: Github Issue #92
The changes in this release are:
Summary:
incompatible behavior fixes on PPI::Statement::Sub->prototype
About the series: perlancar's 2014 Advent Calendar: Introduction to a selection of 24 modules which I published in 2014. Table of contents.
jpath (from App-jpath distribution) is a simple command-line interface wrapper for JSON::Path written by TOBYINK. With the provided jpath utility you can quickly select and transform some branch/node of a data structure. As a bonus, jpath also accepts/outputs Perl and YAML in addition to JSON.
A quick primer on JSON Path: $. to get everything as is, $.keyname to get hash value by key, $.[12] to get array element by index, $.[1,2,3] to get several elements (union), $.[*] to get all array elements, ?(...) to apply a filter (the Perl variant has some syntax modification for the filter). There are a few other constructs provided, please see the linked JSON Path page.
I was looking through the code of the Rakudo implementation of Perl6 where I noticed that it defines pi as my constant pi = 3.14159_26535_89793_238e0; ( with an alias my constant π := pi; )
I immediately remembered that for a subset of fractional numbers Perl6 has a type that stores them without the loss of precision that generally accompanies floating point math. That type is of course the Rat (and FatRat) type. So of course I type pi.Rat into the REPL, it then prints 3.141593 which is obviously nowhere near as precise as the result of just typing pi into the REPL 3.14159265358979.
I wanted to see the numerator and denominator values that Perl chose to use so I typed pi.Rat.perl and got <355/113>, which is nowhere near as precise as the Rat type is capable of handling. That was just the entrance to the rabbit hole.
I am in the process of authoring a talk for Sydney PM as an intro to HTML::FormFu (via Catalyst). The draft of which follows, to which I would welcome feedback and suggestions.
HTML::FormFu
Efficient web forms.
So you can leave at 5pm each day.
Web frameworks like Catalyst, Mojolicious & Dancer take care of repetitive things in web app development such as:
Connecting your code to an environment (mod_perl1/2, cgi, fast_cgi, nginx_perl etc. ok * Plack does a lot of this)
Mapping uri requests to code
Authentication
Authorization
Sessions
Connecting to databases & ORM's
Serialization/Deserialization (JSON, XML etc)
Templating (built on TT, Alloy etc)
Logging/Debugging levels
SiteMaps, Caching, Browser detection
Code Bootstrappers
Whats missing is form generation and validation.
It's very rare not to have form's in any software - business applications have lots of them.
They are very boring and repetitive, prone to mistakes and bugs as a result.
Data types are frequenly the same things: names, addresses, emails, phone numbers, etc.
01:41 < zzzzzzzzzz> Is there no site that gives a current status of Perl6 work
that a non-guru could follow?
01:42 < zzzzzzzzzz> Most of the hits under
https://duckduckgo.com/?q=current+state+of+Perl6 are ca.
2010 and even http://perl6.org/compilers/features is close
to two months old.
...
01:47 < zzzzzzzzzz> That's the impression I get but I have a hard
time getting much farther than that. For example, "what
exactly do I download to start learning, and why those bits
instead of other bits?"
...
01:52 < zzzzzzzzzz> Whichever. A site that took a snapshot of the state every
quarter or two would make it a lot easier for relative
noobs to get up to speed and start learning things.
This is a feeling I've shared for a while. Working out where Perl 6 is takes a bit of archeology, trying to figure out what the Compiler Feature matrix means.
Anyway, I've taken a stab at trying to create a very short, simple, regularly updated set of answers: http://perl6.guide/, hopefully accessible to Perl 5 developers and random other developers. It's on Github (there's a link in there), so if you think I've gotten something wrong, or want to update it, please send me a pull request.
This month has been quite a busy one for me, so I haven't had much chance to work on my (in-progress) book. However, I have had some time to start work on a short talk for London Perl Workshop 2014 which will cover some of the OO best practices followed in the book. (At the time of writing, I've not yet heard whether the talk has been accepted/scheduled.)
A week ago I mentioned that I've started to create a clone of search.cpan.org using the MetaCPAN API as back-end. I've also promised to record a series of screencasts explaining the process. Something, that can be very useful if you need to rewrite an application and you can't read the source-code.