Perl in Pop Culture
Watch the last 30 seconds of this video.
Watch the last 30 seconds of this video.
As if I did not have enough modules to take care already, I just started a new one. It is still on its beta version as I did not have much time to test it, and write a decent API. It is available in the usual place: https://metacpan.org/release/AMBS/Lingua-Identify-CLD-0.01_01
This is an interface to a library by Google for language detection. As far as I could understand, it is part of the Chrome browser, and was just released as open source. Details here: http://code.google.com/p/chromium-compact-language-detector/
It is available at GitHub, and I am happy to receive issues or pull requests. Just bear in mind that no API is still defined (although I have an idea of what I want) and that I do not have much time to solve your issues right ahead.
Finally, a thanks to Jean Véronis that pointed me the library and asked kindly for a Perl interface to it.
You may have seen this:
I had debugger syntax highlighting working before, but I overcomplicated it and never figured out how to approach the problem.
I was inspired to try again by Mithaldu's post about augmenting the debugger. Once I realized that I had a much better strategy than previously, the code was straightforward.
I tested it on 5.12.2. I offer no guarantees. It's on Github as DB--Color. You don't like it? Fix it :)
If you saw @kraih's recent MetaCPAN tweet, you'll know that MetaCPAN's ++ feature has been gamed. Now, we were aware there was some potential for gaming. Initially you needed a PAUSE id to be able to ++, but this had an unexpected side effect in that there were some requests for PAUSE accounts with the justification of "I'd like to be able to ++ on MetaCPAN". Because this placed an additional burden on the already busy PAUSE admins, we were asked to remove this requirement.
Linode is sponsoring a beer party at YAPC::NA 2012. We’ll have beer, wine, soda, and water available for an hour before the banquet at YAPC this year. Thanks to Linode for being so generous!
[From the YAPC::NA Blog.]
First of all, let me start by saying how appreciative I am to the Perl weekly newsletter http://perlweekly.com for making me aware of Citrus Perl in the first place. I've wanted to make robust GUI apps in Perl for sometime and this software appears to give me the tools I need to do just that.
The install
http://www.citrusperl.com/platform/osx32.html
I currently run Snow Leopard and I wanted to be able to create apps for all recent version of OSX, so I chose the u32 build.
Before I cover the main topic of this entry, here are some short news and action items:
If you have not acted against SOPA - the proposed online blacklist/censorship bill, you should. Follow the link for information on how to act against it.
I have announced the next Tel Aviv Perl Mongers meeting on my technical journal on LiveJournal.com. It will take place this Wednesday, on 28 December, 2011. More information in the link.
Anarchy Golf is a new server for Code Golf, which are online programming competitions for implementing code as shortly as possible. It supports Perl 5, Perl 6 and many other languages. There is an active challenge, where the only Perl 5 submission so far is mine, so I could use some competition.
Now for the main topic of the post. Recently, three patches were integrated into the perl-5 core implementing new features in the perl debugger:
I have created an official web site for Marpa. Marpa is attracting new users, to the point where I thought it might be useful to have a site to act as a central directory. The official web site won't have much in the way of new content. With new content, I plan to continue to do what I've been doing -- post it to this blog.
I've started the site with an annotated list of the most important Marpa-related posts in this blog. I hope this will help people newly interested in Marpa figure out where they want to start. Those who've been following this blog for a while might also want to check the list to see if they've missed anything worthwhile.
Stevan Little will be giving a talk at YAPC::NA 2012 described as:
Introduced at YAPC::NA 2011, the Jackalope web-service framework was still a work-in-progress. Now a year later, Jackalope is still a work-in-progress but has seen over a year of real world usage. Come to hear what worked and what didn’t work about the framework and about building REST web-services for a large organization.
[From the YAPC::NA Blog.]
I like yaml so use some idea from Devel-Refactor
I write converter perl var to
yaml
#!/usr/bin/env perl
######################################
# $URL: http://mishin.narod.ru $
# $Date: 2011-12-23 19:53:20 +0300 (Web, 14 Sep 2011) $
# $Author: mishin nikolay $
# $Revision: 1.02 $
# $Source: convert_var_to_yaml.pl $
# $Description: convert perl variables to yaml format $
##############################################################################
#use YAML::Tiny;
#use FindBin '$Bin';
#my $config_name = 'config.yml';
#my $yaml = YAML::Tiny::LoadFile( $Bin . qq{/} . $config_name );
#use Smart::Comments;
my @input_data = ;
#my $self;
#print ext('my $count_xml = 10000;');
my @data_in_yaml = map { extract_var($_) } @input_data;
print join '', @data_in_yaml;
my @data_get_yaml = map { invoke_yaml($_) } @input_data;
print join '', @data_get_yaml;
sub extract_var {
my ($string) = @_;
$reg = '\s*my\s*[\$\@]+(\w+)\s*=\s*([^; ]+)\s*;';
if ( $string =~ /$reg/g ) {
$var = $1;
$value = $2;
}
return $var . ': ' . $value . "\n";
}
sub invoke_yaml {
my ($string) = @_;
my $yaml_row;
$reg = '\s*(my\s*[\$\@](\w+)\s*=)\s*([^; ]+)\s*;';
if ( $string =~ /$reg/g ) {
$var = $1;
$val_name = $2;
$yaml_row = $var . '$yaml->{' . $val_name . '};';
}
return $yaml_row . "\n";
}
__DATA__
my $count_xml = 10000;
my $test_file = 'test_message.xml';
my $orig_idx_file = 'orig_test_message.xml.idx';
my $commit_size = 1000;
Mojocast Monday brings you a high-level overview of Mojo::UserAgent, the client side of Mojolicious. DOM Walking, CSS selectors, and watching live requests are just a couple of the things you'll see.
If this is your first exposure to mojocasts, you might want to start with the first episode.
Merry Christmas and Happy Unicorns!
Every since I started work on GraphViz2 and Graph::Easy::Marpa I was frustrated by Firefox in that it would display an SVG image in isolation by not when I used a 'img' style link to the image, i.e. from within a web page.
But googling eventually led me to a site where the author said he had better results with 'embed'.
So, I switched to embed and it worked. Chrome of course had never had such a problem.
This means I no longer have to produce 2 sets of demos, PNG and SVG, since I can now assume Firefox users will have no problem displaying the images.
If anyone can tell me definitively why this should be the case, I love to know...
The demo pages are at GraphViz2 demo and at Graph::Easy::Marpa demo.
There will be a Game Room at YAPC::NA 2012. Our sponsor cPanel has helped us arrange this spectacular extra social event.
The idea was actually brought up on ideas.yapcna.org several times in various ways. Some people suggested doing a poker tournament, while others wanted to play RPGs, while others wanted to play board and card games, while still others wanted to do a LAN party. (Who knew there were so many gamers in the Perl community?) We decided to do them all in the form of a game room.
perldoc perlsyn | perl -ne 's/^.*?"|\\.*$//g,print if/1\.\.15/'
In my chapter on subroutines, I need to explain recursion. One example program I give draws mazes recursively. Here's a variation of the program, somewhat expanded beyond the book example.
Some days ago, Marpa::XS reached version 1.0. Jeffrey Kegler, Marpa's godfather already wrote a some blogs about the algorithm operating behind.
In order to get a feeling on how to use Marpa, I decided to try it for parsing CSS. Thankfully, the official grammar for CSS is available. So I tried to become a friend of Marpa::XS. I was used to work with Parse::RecDescent in the past, so I could not imagine to get into trouble. However, using both modules is different. Parse::RecDescent handles the scanning process by itself and allows various shortcuts for repeating elements inside a grammar. Marpa on the other hand needs a separate scanner to feed it with tokens and only allows very simple grammar rules. Parse::RecDescent combines parser code and grammar rules in one string. Marpa keeps the grammar clean and calls action methods based on rules defined inside the grammar.
Glen Hinkle will be giving a talk at YAPC::NA 2012 described as:
Get an overview of what Mojolicious has to offer, and what makes it unique in the Perl community. Learn how to quickly make and deploy a web app (even if you have no web development experience) and know what resources are available to you going forward.
Best served with beginners, intermediates looking for direction, and those curious to see what this whole mojo thing is all about.
Get on the bus!
[From the YAPC::NA Blog.]
Some of my scripts are still set in stone age when it comes to the practice of sending emails. They almost invariably use Mail::Sendmail, a module that has not been updated since 2003 (and why should it if it doesn't break, right?). So far there's no complaints. The usual incantation for sending email using this module is:
use Mail::Sendmail;
mail(From=>$rfc_from, Sender=>$env_sender, Subject=>$subject,
To=>$rcpt, Cc=>$other_rcpt,
Message=>$body) or warn "Can't send mail: $Mail::Sendmail::error";
But today I need to switch transport to sendmail. Despite what the name might suggest, Mail::Sendmail uses SMTP for transport and there's no alternative transport. There's also no support for SMTP auth, which my SMTP server now requires even for access from localhost. From what I read and tried once or twice in the past, the current "best practice" or recommended way is to use Email::Sender. Here's the incantation for sending mail using sendmail:
I wrote the following on Facebook:
I have a very good reason for including this regular expression in my book. It's a tiny part of a much longer one I once wrote.
(?x-ism:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:
(?=[.]?[0123456789])(?:[0123456789]*)(?:(?:[.])(?:
[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+
))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))(?:\s*
(?-xism:(?:\*\*|[-+*/%]))\s*(?-xism:(?!\.(?![0-9]))(?:(?:
(?i)(?:[+-]?)(?:(?=[.]?[0123456789])(?:[0123456789]*)(?:
(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:
[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)
\b)))*)
At which point, many people piled on and criticized this without asking why I was going to include this. I should have known better than to make such a cryptic post and then head to bed, so here's the explanation.
How should a JSON parser handle character strings with non-ASCII characters? My humble opinion: fatal error. Here's what the JSON parsers on my machine did:
http://pastebin.com/mwui3iDy
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.