Hello World
Hello World,
Trying to reverse my I/O.
Hello World,
Trying to reverse my I/O.
Module::Starter 1.54 was recently released. I felt like blogging a bit about it.
Module::Starter is one of my favorite projects in the Perl community and on CPAN. I use it whenever I want to start a new module or program. It's very simple (read: beginner-friendly), modest and provides what I don't feel like doing myself. It has boilerplate files, text and tests and keeps updating those with habits that are considered "best practice", such as replacing the default licensing term we use.
Recently I've had the pleasure and honor of contributing to this project. I've made several changes mainly taking care of tickets and patches people submitted, making this release a fixer upper release. Following releases will contain some bigger and more exciting changes.
I want to take this chance to thank Andy Lester, Ricardo Signes, Shlomi Fish and anyone else involved with Module::Starter. Also, I want to thank some lesser-known contributors to Module::Starter, those that send bug reports, feature requests and patches (on my god, patches *drool*).
libnova is a Celestial Mechanics, Astrometry and Astrodynamics Library written in C. Just yesterday, I uploaded an inital, thin XS wrapper to CPAN as Astro::Nova, so we can use it from Perl.
Here's a simple example that calculates the current moon rise, transit and set times at my home in Karlsruhe using Astro::Nova. It's quite similar to the equivalent example of the C version.
I recently started working on my first CPAN module, Project::Euler. This is simply my effort of solving the problems posted on http://projecteuler.net using modern Perl strategies / modules. I will be making an effort to post about my thoughts that I have while coding as well as problems that I ran into and how I overcame them.
Being as this is my first module uploaded with PAUSE, I've already ran into many snags and continue to muck up some simple things that will no doubt disappear once I am fully comfortable with how CPAN works. I may post some entries about the issues I've encountered already but for now I will just be posting all future ones.
With any luck, I will help others who have been hesitant posting to CPAN see it through the eyes of a newbie and realize that it isn't all that bad!
I have been using Emacs for decades. I am totally happy with it (indeed, it keeps getting better and better!) and am not looking for another editor. Nonetheless I like to keep abreast of things, so when new tools become available, I like to check them out.
For a while now, I have been hearing about Padre, an IDE written in Perl. However, until recently, I wasn't able to get it to work. Granted, I never tried anything more than
PERL_MM_USE_DEFAULT=1 cpan Padre
I recently tried installing version 0.50 on a Windows machine with the fancy .msi installer (recommended!). It appeared to install okay, but when I ran it, nothing happened. Nothing. At all. So I tried to uninstall it, but that just hung the machine. Grr. After powering the thing off and back on again, I removed the C:\strawberry directory and then ran uninstall. Whew!
But today I ran
PERL_MM_USE_DEFAULT=1 cpan Padre
Working on rights modeling for programmes and one of the issues deals with the availability window of online content. It might be available for a day, a week, a month, etc. It looks like this in our XML:
<availability_window unit="days" value="1"/>
<availability_window unit="days" value="7"/>
<availability_window unit="days" value="30"/>
The availability window is an extremely important part of our rights model and if we get it wrong, we're violating contractual agreements with people who produce content for the BBC. In short: don't get this wrong.
As it turns out, there is some content which has what is called "endless availability". This is content which, when made public, is never removed. We represent this availability window with the following element:
<availability_window/>
It turns out that this was a mistake because people assumed it meant this:
<!-- not available -->
<availability_window unit="days" value="0"/>
This is a stupid hack and you shouldn't do it. But it was one of those things where I wondered if it would work and had to try it.
One of the things that annoys me tremendously about HTML is that you can't write a self-closing script
tag. E.g.
<script type="text/javascript" src="/foo.js" />
is invalid. The <script>
element is not allowed to be empty because it may contain inline code, and HTML is not smart enough to turn that feature on or off based on the presence of an attribute. (And it probably shouldn't be.) So you have to do <script ... ></script>
every time.
perl -e " print 'Hello,world.' "
I am in the process of writing Yet Another Job Queue, Cantella::JobQueue.
I decided from the beginning that I wanted a well-defined API for the storage layer, so that as different back ends would be easy to write and swap around. While writing the tests for the first one, I encountered a problem that’s been haunting me since: how to deal with locks.
Originally, I imagined a job would either be locked, or not locked and manager processes would be in charge of releasing locks if workers died / failed. Then I started thinking, what if a manager process dies? Who releases the locks? So I decided to add time-based automatic lock expiration. This introduced a new problem, a possible race condition. What if a job takes so long that it’s lock times out before the job is done? What do I do then?
A possibility is to have a manager process / thread that monitors its workers and updates the lock-expiry time, which is the route I am likely to take. I don’t particularly like it, but I can’t come up with anything better right now.
I’d love to hear from anyone that has any experience with this kind of problem.
# I had to say
# push my @entries,<<EOF;
# just to make it appear as:
# push my @entries,<<EOF;
EOE
My fabulous new nook arrived today. The packaging was atrocious, as can be expected for any new electronic gizmo, but once I broke out the Jaws of Life and freed the nook from its captivity, I was very pleased indeed. The first thing I did was to load it up with my PDF copy of Mark Jason Dominus's Higher Order Perl, which is now available for free and which every Perl programmer should read once a year or so.
I fixed that. The fix was pretty trivial: basically, the C code in the implementation of smart match was creating two hashes, called seen_this and seen_other; however, a typo made it so only seen_this was actually created. Segfaults ensued if the code was trying to use seen_other.
Do you see the language problem here? The code to create seen_this was copied and pasted to the code to create seen_other, but not all occurrences of the variable were renamed. Because in C, it's difficult to factorize this code without much programming overhead. (In that case, pointers to pointers.)
But in Perl, we have foreach and aliasing to $_. That's a great tool to avoid cut and paste, and reducing cut and paste will always improve maintainability. And that's why I prefer writing stuff like
$_ = $_ ? "<$_>" : "-" for $x, $y;than
$x = $x ? "<$x>" : "-"; $y = $y ? "<$y>" : "-";
It's a lot of fun to contribute to other people's code (especially code you're using) and it's very fulfilling. Some people say it's a downer when your code isn't accepted, and I can understand that. However, the serious downer is when your code gets ignored.
When I go over a module, I go over the ticket list. When I see a ticket from over a year and it's still "new", it disappoints me and when I contribute to a project and it takes six months to get a reply, it disappoints me.
The following is ongoing on my private branch of the CPAN dist Net::RackSpace::CloudServers, in which I'm creating an App::Cmd interface to the module:
So I finally managed to attend a Perl workshop over the weekend and it was awesome! I saw some excellent talks and even got a goddie bag ... I was not expecting that. Some personal highlights:
Most entertaining talk
For me it was Piers Crawleys lightening talk/song "don't care how you young people talk to one another but don't take that tone with your mother". Can I have the lyrics please ;)
Most useful/relevant talk
Plack/PSGI by Miyagawa. It's great to see that folk much smarter than myself are solving issues that directly influence my work. More of stuff like this and I won't be forced to use Ruby any time soon ;)
Most "what the hell was he on about" talk
Definitely Matt Trout's BEGINing Perl talk. Something about compilation units, Moose, antlers, Damian Conway, black magic, e.t.c. I understood about 30% of that ... about 20% more than I anticipated ;)
I left with a satisfying feeling that I am somewhat better than I give myself credit for (mostly because I understood any of Matt Trout's talk). I missed most of the conference including the trip to the pub and did not socialize as much as I would have liked. Perhaps in my next conference I'll be more friendly :)
All in all a great experience that I would recommend to any one!
My editor of choice is Emacs. Like Perl, one of its strengths is its flexibility. (some would argue this a weakness. to each their own) Here's just one example I recently found... you can extend Emacs to change the cursor based on what mode you are in (normal, read-only, overwrite)
http://emacs-fu.blogspot.com/2009/12/changing-cursor-color-and-shape.html
<rant>
Rapidshare deletes illegal files, so instead of sharing Rapidshare links, sites nowadays apparently started sharing .dlc files (or so I've heard). DLC is an encrypted container format. It is very very stupid. I'll elaborate.
Let's break it down:I really wish we had a proper D language (the D languages for the relational model, that is). Here's one way to create a table in SQL:
CREATE TABLE foo (
id INTEGER NOT NULL,
name VARCHAR(255) NOT NULL,
status INTEGER NOT NULL,
location VARCHAR(20) NOT NULL,
UNIQUE(id)
);
Here's the analogous relation in Tutorial D:
VAR foo BASE
RELATION { id INT, name CHAR, status INT, location CHAR }
KEY { id };
Which would you rather type, day in, day out?
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.