Our first Effective Perl talks

At Frozen Perl 2010, Josh and I gave our first talks based on Effective Perl Programming, 2nd Edition.

I gave a day-long master class as the first version of what we are turning into a full training course. I covered regexes, Unicode, pack, advanced subroutines, and tricks with filehandles. Each of those sections covered most of the material from those chapters in the book, and during the course I picked up even more tricks that we'll add to the Effective Perler blog as well as later classes. I'm thinking about releasing some of the slides next week when I have some time to take care of some of the notes that I made.

Josh gave a short talk on Unicode. Several of my students remarked how it was nice to see some of the same material twice since there's a lot to pay attention to in Unicode. His slides are in Google Docs, but he's adjusting some of the images so he doesn't get sued for the comments he made about the Minnesota Vikings. It's not really his fault if they aren't as good as the Bears. Everyone nag him to make his slides available with the rest of the Frozen Perl talks.

If you want one of our talks at your conference, let us know.

How do you handle Amazon EC2's failures

We've just moved our website to Amazon EC2, and within about 2 hours of going live, or proxy server went down. Just disappeared. We couldn't even terminate the instance.

OK, temporary glitch. It happens.

2 weeks go by, then last night, our alarms go crazy. All 3 database servers have gone down. They're there, just not responding to ssh or even ping.

We try to reboot the instances. From the console log, I can see that they reboot. Still not accessible. I launch another instance of our DB AMI. It boots, but is also unresponsive.

Eventually we boot a vanilla AMI, reinstall the DB and attach the EBS volumes.

Next surprise - 2 of our EBS volumes have disappeared - or at least the data on them has. Fortunately, they were redundant copies. But what happens if next time they're not?

All in all we had 2 hours of downtime. More than the previous 3 years with dedicated servers put together.

How on earth do other companies maintain their uptime (and data!) on a service that seems to fail way too frequently?

Even more CPANdeps stuff

Added a coupla features over the weekend. First, you can collapse and expand parts of the tree if you have Javascript and CSS turned on. Second, now that CPANTS's tool for finding what distributions depend on a given distribution no longer works, I've implemented it myself. It's a bit ergonomically crude, but is more accurate than CPANTS was.

Spock and Data look at CPAN

In the two Star Trek series, the characters of Data and Spock pose a question: What would it be like to be able to make decisions on a largely, or even purely, logical basis? Not widely known is that this is a question with an answer based on evidence.

Why your talk won't be at OSCON

About a week ago, the call for proposals for the Open Source Conference closed. It's a bit fuzzy because many people only realize what month (or year) it is only after the submission link disappears, so we let a few extra proposals slip in. Don't ask now: it's too late. For reals this time.

As part of the Perl Track committee, I just reviewed all of the proposals where the submitter marked it as a "Perl" talk. Several other people from the Perl track also reviewed them. There are going to be some very nice presentations this year, and at least one demonstration of highly advanced Perl technology that you'll want to see twice in a row, and maybe a third time at the end of the conference.

Forcing IE to accept script tags in innerHTML

So, my first blog post, and instead of Perl, I'm writing about Javascript.

I'm using a common idiom:

  • AJAX call returns HTML with embedded script tags
  • create a temporary <div>
  • div.innerHTML = request.responseText
  • move the children of the div to the appropriate spot
Firefox conveniently executes the script texts. Opera and Safari require extra steps to execute the script contents (eg, globalEval in jquery), and IE does whatever the hell it pleases.

IE usually works with globalEval, except when it doesn't.  I found that if the AJAX response was just a single script tag, then IE would filter it out.  But script tags were being created in certain circumstances.

Long story short, if you need to return a single <script> tag, wrap it in a <form> tag.  For whatever reason, IE will then accept it as innerHTML and create the script node, which you can then execute with globalEval or similar

Unhappy with @INC

Ever since I upgraded to Snow Leopard, my Perl has been unstable. I've fixed most of it, but I sometimes have strange behavior. Today I discovered why (and why didn't I notice this sooner?)

@INC:
/System/Library/Perl/5.10.1/darwin-2level
/System/Library/Perl/5.10.1
/Library/Perl/5.10.1/darwin-2level
/Library/Perl/5.10.1
/Library/Perl/5.10.0
/Library/Perl/5.8.9
/Library/Perl
/Network/Library/Perl/5.10.1/darwin-2level
/Network/Library/Perl/5.10.1
/Network/Library/Perl

Great. A bunch older Perl's have somehow made their way into my @INC. Time to recompile.

More CPANdeps jibber-jabber

Another coupla small updates to CPANdeps.

First, you can now collapse parts of the tree.

Second, a small bugfix for distributions with weirdo version.pm-stylee v1.2.3 versions. Thes dists are buggy, of course, as version *numbers* should be, well, they should be *numbers*. But as they're on the CPAN, I have to support them.

Now, can someone explain why this 'ere form what I'm filling in has seperate fields for "tags" and "keywords"? I thought that "tag" was just a stupid web 2.0 neologism for "keyword", so why are they seperate?

reading input from a file

hello...
i have recently started learning perl.....and having issues when i try to read input from another file. the details of a script that i tried to run are as follows:

i made a text file by the name "text.txt" and the contents were
Sidra|38|BE
Hira|48|BE
Shagufta|50|BE

Then i wrote the following script

open(DAT, "text.txt");
$data_file=" text.txt ";
open(DAT, $data_file);
@raw_data=;
close(DAT);
foreach $student (@raw_data)
{
chomp($student);
($name,$roll_no,$class)=split(/\|/,$student);
print "The student $name bearing roll number $roll_no is in class $class";
print "
\n";
}


the script produces no output and displays a message saying
"readline () closed filehandle at line "
I tried the same with another file by the name "text.dat" holding the same data but it did not work either. Please help me out resolving this issue.
Thankyou...

Contributing is easy!

I thought I would share my experience of submitting a module to CPAN for the first time. In summary: it's stupidly easy and if I can do it, so can you.

I'm not the best Perl coder and therefore I rely heavily on CPAN modules to do the real work. Every now and again I stumble upon bugs, many of which are simple to fix after a little debugging. However, some modules aren't heavily maintained and some haven't been touched in years. Bugs that are filed on RT can go unanswered, gathering digital dust while your development machine is riddled with heavily modified modules.

The solution? In my case it was as easy as discussing a few changes with the module author, who added me as a co-maintainer. That allows me to upload new versions, fix tickets in the bug queue and probably many other things I've not discovered.

POE Palm Sync Monitor

I am weird.

i have a Motorola Droid and a first generation iPhone which I use on WiFi only. But I really can't get myself to use either of them for task management.

Nothing beats the feel of my Palm Tungsten C keyboard. And nothing really beats the simplicity of the Palm ToDo List. Well, not really nothing, but you know what I mean.

I was surprised and happy to notice active development still taking place on p5-Palm. Today, I decided to resurrect an old project I had started to create a Palm Sync daemon on my home server.

First, I confirmed that pilot-link was up and running on my server. Next, I refreshed my memory on the commands used to run a WiFi sync.The first step is to make sure the user of the Tungsten C and the user of pilot-link are one and the same. This overwrites the user on the device, so proceed with caution.

pilot-install-user -p net:any -i 1000 -u mike

Updates for Net-Amazon-MechanicalTurk

I noticed How can I fix Net::Amazon::MechanicalTurk's failing tests? on Stackoverflow. There are a couple of patches in RT and another one on Dave Viner's blog under Amazon Mechanical Turk Perl Library Error. I applied the patches and uploaded an unauthorized release so CPAN Testers can have a wack at it.

If you are the author of this module, use it, or otherwise have an interest in its health, please let me know. I don't use it at all, but I know how to make broken distros work again. There are still lots of problems, but I only did the minimum to get the tests to pass.

Frozen Perl 2010: Days -3..-1

The drive Wednesday up to St. Paul went well, no major meltdowns or fussing.

Had dinner at the Blue Door Pub. I had the Jiffy burger and a bunch of good beer. A bit too much peanut butter for my taste. The Purvis at XXX seems to have a better balance of peanut butter to burger.

Thursday was mostly focused on getting to Punch for lunch. We then had Taste of Thai for dinner.

Friday was awesome. I took brian d foy's Effective Perl Programming class. Nothing like beta testing (more like alpha since brian did mention this was the first time teaching it) a class. Since I've taking his Mastering Perl class a couple years ago at OSCON I would say half the content was familiar from that and general Perl stuff I've done/read about. The rest was golden (mostly Unicode stuff). I'm looking forward to the second edition of the book that the class is based on.

Tracking Down Bug Reports

I often find that test reports I get from smokers are not terribly useful for failures. Sometimes it's obvious. Other times it's not. One thing which helps a bit is this bit in your t/load.t test:

diag(
    "Testing My::Module $My::Module::VERSION, Perl $], $^X"
); 

In the CPAN testers reports, you can click on a test report and instantly see the module version, Perl version and path to the current Perl (arguably not as useful).

I like to go a step further and include information about all modules I claim to require. For my t/00-load.t for Test::Most, I have the following:

distributed data analysis and reporting and perl, ...

so I was asked this question regarding our users and our products
and such. wanting a quantitative numerical result,
- I quickly (less than 5 minutes) wrote up a map-reduce (+ reduce) job,
- submitted it to our array of servers,
- and in less than 10 seconds, I had the answer.

actual job code (names changed):

Sense & Maintainability

There is empirical evidence that Perl is an inherently maintainable language. The Software Productivity Research group have published 2 comprehensive surveys of programmer productivity across different languages and problem domains. One was published in 1996, the other in 2006. The results in both are consistent - for overall perl productivity scores & when perl is compared against other popular languages.

Function points were used as the data collection method and the survey covered the whole dev lifecycle. The actual figures are not too important - suffice it to say that both surveys found that perl is far more productive than C & generally significantly more productive than Java.

SQL scores even higher, btw, albeit in its specialist field of relational data manipulation.

Productivity != Maintainability though?

True - but to be productive throughout the lifecycle the maintainability must be at-worst acceptable w.r.t to design,implement,test.

Naturally questions can asked of the method & the results. SPR themselves spell out the limitations, so take with appropriate seasoning. That said the consistency of the results might induce speculation on:

s3syncit - Ubuntu One and DropBox Replacement Written in Perl

For a while I have had two itches to scratch. Firstly, I wanted a simple set of libraries to interface to the Amazon Web Services. Secondly, by having those, I could do my own remote storage of various important files.

Almost 2 years ago I wrote the start of Project AwsSum in Perl. They are simple but they work and also come with some small command line tools which do as you want.

The itch for those interfaces has mostly gone. I do need to add some latest updates to the interfaces but they're ok in all honesty and those who want those new features would only take a few mins to add them :)

Remote Backup

The 2nd itch has been bugging me for a long time though. In the example folder of the repo there is a command line tool called s3bak and for ages I have been using it to store my files. However it has one major disadvantage, the pushing and pulling is manual.

CPAN Testers Summary - January 2010 - The Wedge

One month to go and work is progressing well on the transformation to CPAN Testers 2.0. Over the last month many changes to the websites have been visible, but just as many changes have been happening behind the scenes. The Metabase is a key part of the transformation, and although work has been going well, it is reaching the point where it'll need some serious testing prior to switch over on 1st march 2010. If you have the time, please join the cpan-testers-discuss mailing list or contact David Golden to let him know what you can help with. See David's CPAN Testers 2.0 mid-January update blog post for a more detailed status update.

Why you should create CPAN distros

On Tuesday, February 23rd, Jeff Thalhammer will speak on why you should create CPAN distros, even for proprietary code. He has worked on worked on several projects where all the private code was organized into CPAN-style distros, and then injected into a local copy of CPAN. They then used the CPAN tool chain to manage the entire build, test, and release process. Jeff Thalhammer's CPAN page: http://search.cpan.org/~thaljef/ Announcement posted via App::PM::Announce RSVP at Meetup - http://www.meetup.com/San-Francisco-Perl-Mongers/calendar/12509158/

Assorted

Some older articles from a (failed) attempt to compete in the Ironman Blogging Challenge. I’ll try to move them over here, although converting from Blogspot’s HTML (or even cleaning up said HTML) to Markdown is a hassle.

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.