I broke $work yesterday when a change I'd made that I thought was mundane was not in fact. I'd changed some code from: if ( keys %$hash_ref ) { to if ( %$hash_ref ) { under the theory that we weren't supporting any perl less than our current production at perl-5.10.0.
What I'd completely missed was that $hash_ref might be undef and that keys %$... would auto-vivify the hash if necessary. Previously, the hash would be created as a side effect of dereferencing it. Afterward, I got an exception because the hash wasn't being automatically created just by looking at it.
The reason for this is keys() is actually an lvalue, something you can assign to. The meaning of keys( %... ) = 8 is actually fairly obscure and not what you would guess if you haven't read the documentation for keys(). Because keys() is an lvalue, the dereference %$... will auto-vivify anything necessary because I might want to modify it.
When I dropped the usage of something strictly defined as an lvalue function, the dereference stopped auto-vivifying and now I had exceptions in production. Wheee!
Larry Wall once said that he could program anything in one-line of Perl given a sufficiently long line. That is, in a language where lines aren't significant, line count is stupid. If you want to count lines, Python is probably your language.
I've just pushed ElasticSearch::AnyEvent - this brings async requests to the Perl ElasticSearch client. It is still lacking proper documentation and any tests, which will soon follow.
The Pittsburgh Perl Workshop is a low-cost technical conference held at the Carnegie Mellon University's Oakland Campus. The workshop will be held on October 9-10 2010.
We are happy to have Larry Wall keynote PPW 2010 in the new Gates and Hillman Centers.
* Talk Proposals
* Classes
* Hack-a-thons
* Sponsors
* Talk Proposals
We do not have deadline for talk proposals yet but please send them sooner than later or you may miss your chance to speak.
The Pittsburgh Perl Workshop 2010 is the perfect opportunity to share your ideas, code, and projects with masses of code-loving Perl hackers. Shouldn't you have a speaking slot at this year's event? Shouldn't you experience the full, PPW-powered glory that only speakers can know?
Of course you should!
Haven't you ...
done interesting stuff for Perl?
written cool code?
seen the future of Perl?
got a story to tell?
got a trick to share?
In fact, if you have anything to say that would interest Perl people,
we want to hear you say it!
Uncapture modifier. The new /r regexp substitution modifier in Perl 5.13.2 indicates that there might be hope for even more modifiers in the future. A possible modifier might be one that ignores all capture groups, which can solve this guy's problem.
require that can also import. I wonder why "require" doesn't also support importing like "use" does: use MODULE_NAME LIST... since it already support "require MODULE_NAME". This way, whenever I want to defer loading some modules, I can just replace "use" with "require" and put the statement under some "if" statement.
the backtick function.. Do you find yourself often having to do use a temporary variable like this, $cmd = "some longish and ".quote("complexly formed")."command"; before doing backtick `$cmd`? This is because unlike in PHP, we have system() but no backtick(). Most probably remnants from shell. There is Capture::Tiny for more general solution but of course it's a bit more cumbersome.
The YAPC::EU 2010 team has uploaded to YouTube videos of the conference in the yapceu2010 channel. There's even one of me presenting the White Camel Awards to cog and to Barbie. I don't think I'm terribly interesting, but I like their comments as they accept their awards.
Paul Fenwick couldn't be there, but maybe someone can convince him to do a video acceptance speech. He's dressed as a Star Fleet officer, a pirate, and a mad scientist. What should he be in the video?
During YAPC::EU mst suggested "why don't you just start Glasgow.pm?"
I talked about it a bit with a friend who'll be back in the country soon enough and even today at work, and I think we may have enough people to kickstart the new Perl mongers group.
I know there are several businesses and people in the West of Scotland who either use or like Perl, so I am hoping that enough of them would like to join the group.
I've sent the request to pm.org's support to reinstate the old Glasgow.pm. I will endeavour to bring the mailing list and website up as soon as possible, and will start reaching out to people who use Perl in the area. Dear lazyweb, could you help me?
There is a tool I recently opensourced. It can be compared to classic SysV init script system or to daemontools, runit or upstart, but it already is better and more flexible at least in some of its properties (otherwise I wouldn't bother to implement it :) ).
It is called Ubic and it is a toolkit for describing daemons in pure perl.
Ubic service is simply a perl object of some class inherited from base Ubic::Service class.
Ubic loads service descriptions from /etc/ubic/service/ directory.
To create your first service, you have to write something like this:
# cat >/etc/ubic/service/test
use Ubic::Service::SimpleDaemon;
return Ubic::Service::SimpleDaemon->new({ bin => "sleep 1000" });
"ubic status" command can show you status of all or some services on host:
# ubic status
test off
ubic-ping running
# ubic status test
test off
Now, as you probably already guessed, to start service you simply have to say "ubic start":
jejky, I got a TPF grant. Even if scheduled it for 7 month, I plan to be ready end of this year. I think it will also appear in the first Module I ever uploaded to CPAN: Perl6::Doc, so you can grok perl 6 too. More info about that on my Perl 6 related blog.
Last weekend i was in Bonn at Froscon standing at perl booth, giving a talk about perls testing modules and we were talking there about educational material. I say education not PR. Because if there was a satan, pr is one of the best evidences of his existence. I speak of education in the best sense. No bragging, no flattering, no hot air. just knowledge, delivered entertaining. As part of that we want posters and slides showing perl code snippets that are eaysy readible, even to python programmers and powerfull. so lets open 4 categories. perl <5.10, 5.8<, modules and 6. I have some ideas but please send me your best lines, so that we can show it at conferences.
I am hoping that the module is in no worse shape today than when I joined the project as a co-maintainer. As I outlined in response to brian's post, I plan to work on multi-threading support for the next release.
I would also like to add more tests.
If you use this module (i.e., if you use LWP or WWW:Mechanize with HTTPS), please try out development versions in the upcoming weeks and report bugs.
If you want newbies to help you with a project - in fixing code, writing tests or even documentation - my course students will be given a course completion project to help out an open source project. That project can be yours!
Background:
I've been very inspired by DJB (Daniel J. Bernstein) and his course on UNIX Security Holes. The highlight to me was how his students interacted with the outside world - something I personally never did while studying programming (or anything else, for that matter) at school. I saw two of my brothers go through their degree (computer science, biology), helped with their homework and even attended some classes. They too never interacted with the outside world! I decided I want this changed in my course.
This entry is about Javascript, not Perl. It's about object identity in particular.
If you have two objects in x and y, you can check whether they're really the same object with x === y. However, as far as I know Javascript provides no way to get an object's address (which you could use as a key in a hashtable or whatever). The following code attempts to fix this problem by adding a unique ID to every object (and I do mean "every"):
Since I maintain a lot of code that wasn't originally written by me, I am in the unfortunate situation that I get to edit code with many different coding and indentation styles on a regular basis. Reformatting usually isn't a good idea since not only may the original author object, but the revision control history is more important than code and indentation style.
I'm a vi(m) user. Modifying the settings to suit whatever insane tab-compression-indentation scheme some crazy emacs user decided on for individual documents is severely annoying. My editor should do this for me. If I was using Padre for my daily work, it would do this for me automatically. Today, finally, I sat down and wrangled vi until it would auto-detect the indentation style of the current document. More precisely, Text::FindIndent does (version 0.09 was just released and is required). Install the module, include this in your .vimrc on one line:
map <F5> <Esc> :perl use Text::FindIndent;VIM::DoCommand($_) for Text::FindIndent->to_vim_commands(join "\n", $curbuf->Get(1..$curbuf->Count()));<CR>
Now, open up somebody else's source code that uses some crazy indentation scheme. Hit F5. Your vi settings have now been marvelously modified to produce the same broken indentation as whatever you opened for editing.
How do you start and daemonize your programs (PSGI apps, fastcgi apps, gearmand, several memcached instances, custom handcoded daemons)?
Do you write custom init scripts?
Use daemontools or upstart?
Do you simply invoke plackup in terminal? :)
Maybe you spawn your fcgi apps directly from your webserver?
Do you need watchdogs? Do you actually write them?
When I search CPAN, I frequently find it hard to tell which modules to choose. Unless my needs are very specialized, there can be lots of modules that do what I need. But how would I know which module is best to choose?
One factor that can help me decide is the number of CPAN dependents each module has. (Don't confuse "dependent" with "dependency"; I use the word "dependent" to mean: other modules that depend on it.) If a module has lots of other modules that depend on it, then I can be relatively certain that the module might be worth relying on.
The information about the modules' dependents is exposed by http://deps.cpantesters.org/depended-on-by.pl, which is rather cumbersome to use.
So, I created a greasemonkey script which dynamically shows the number of dependents for each module on the search.cpan.org search results. It then displays the list of distributions in order of their numbers of dependents.
For CPANPLUS users this just got a little bit easier.
Task::CPANPLUS::Metabase should make configuring CPANPLUS a lot easier. Simply install Task::CPANPLUS::Metabase, which will install all the necessary modules, then run the metabase_cpanp script to setup a Metabase ID file and configure CPANPLUS for sending test reports
I recently read a blog post by Alex Miller about Clojure multi-methods.
It described and answered a question his friend had asked him, as well as discussing some related problems. I'm going to showcase the different options Perl 6 provides for solving these same problems. Here's the initial question:
Is it possible to write a multimethod that has defmethods which handle ranges of values? For example, say that a person has an age. Can I write a multimethod that accepts a person as a parameter and returns "child" if age < 16, "adult" if 16 <= age < 66 and "senior" if age >= 66?
As in Clojure, the answer is "Sure." In keeping with TIMTOWDI, Perl 6 provides several ways to do this.
Like political views,
parsers are often divided into left and right.
Also like political views,
the left-right classification is more
hindrance than help in some cases.
Earley's algorithm (my main interest) is one
algorithm that does not fall into either category.
In this post I want to start to
talk about those parsers which can be neatly
classed as left or right.
First off, to say a parser is a left or right parser
does not describe
the direction in which the parser works.
The working direction of any parser
is always left-to-right,
except in the very rare cases that it is stated otherwise.
Every treatment of parsing theory I've seen follows this
convention.
Right-to-left parsing is useful sometimes in practice,
but the theory of right-to-left parsing
is simply a mirror image of the theory
for left-to-right parsing.
Uvar magic must die. Maybe it’s too late for a complete removal, but it’s use should at least be discouraged. One of the reasons is that it’s actually two very different things that don’t have all that much in common.
Scalar uvar magic
Scalar uvar magic isn’t actually evil, it’s just fairly useless. It’s a way to add get and set hooks to scalars. It may have been a useful interface back when it was introduced in 1993, but with the introduction of custom magic vtables in 5.8 it stopped particularly useful. The new interface is more powerful in many ways and in typical cases it that takes less code to use. There’s absolutely no reason why anyone should still be using scalar uvar magic unless you have to maintain compatibility with 5.6.