mpeters's Journal http://use.perl.org/~mpeters/journal/ mpeters's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:16:46+00:00 pudge pudge@perl.org Technology hourly 1 1970-01-01T00:00+00:00 mpeters's Journal http://use.perl.org/images/topics/useperl.gif http://use.perl.org/~mpeters/journal/ Perl hashes in comparison to C, C++, Python and Ruby http://use.perl.org/~mpeters/journal/40268?from=rss I just came across <a href="http://incise.org/hash-table-benchmarks.html">this blog post</a> which benchmarks several hash implementations in C and C++ including the hashes or Python and Ruby. <br> <br> I was wondering if someone wanted to <a href="http://github.com/mackstann/hash-table-shootout">fork the benchmarks on GitHub</a> and add a Perl entry. I haven't done C in a while and I've never done XS, so I'm probably not the best person for that job. <br> <br> Any volunteers? mpeters 2010-03-25T14:47:41+00:00 journal blogs.perl.org http://use.perl.org/~mpeters/journal/40174?from=rss <p>I'm trying to like the new site blogs.perl.org but every time I try to use it something goes wrong. Every time I try to comment on a post I get this strange error message (It's happened to me every day for at least a week. I decided to ignore the first few times since all sites have problems and it is still beta, but I guess I just got too annoyed today):</p><blockquote><div><p>Comment Submission Error</p><p>Your comment submission failed for the following reasons: Text entered was wrong. Try again.</p></div></blockquote><p>Really? My text was wrong? Do tell, how could it have been made "right".</p><p>Not only is this error message completely unhelpful, but it takes me to a separate page where I have to click my browser's back button to try again. Really? That's so 90's.</p><p>I've tried clearing out any blogs.perl.org cookies that might be bad for some reason; I've tried changing my content, my name, my url, etc. Nothing seems to work. Anyone know what's going on or have a clue as to how I can fix this?</p> mpeters 2010-02-11T15:35:07+00:00 journal Obligatory giving of Thanks! http://use.perl.org/~mpeters/journal/39950?from=rss I'm currently waiting for the turkey and stuffing to cook and am feeling really grateful for lots of things, so I thought I'd share some of my programming gratitude here. In no particular order, I'm thankful for: <ul> <li> <strong>Mark Stosberg</strong> - Not only is he the driving force behind the CGI::App community but he's also great at helping out with important modules that have fallen a little stale (CGI.pm, CGI::Session, Data::FormValidator). He's also been a patient follower and contributor to my Smolder project. </li><li> <strong>Brad Oaks</strong> - Not a CPAN contributor, but the main organizing effort behind Raleigh.pm and a fellow co-worker. Our technical meetings are good geekery and our social meetings are pretty fun too. Not all of us programmers are good at organizing social things, so I'm glad that he is. Not only is he a good sounding board for my ideas at work but he makes me think of things that I didn't see on my own. </li><li> <strong>Ricardo Signes</strong> - Great speaker, prolific module author and very funny guy. I've had the privilege of hanging out with him at lots of YAPCs and a couple Perl QA Workshops and it's always a blast. His willingness to delve into the abyss that is Email and make it sane (or saner) for the rest of us is enough to earn him permanent Perl sainthood. </li><li> <strong>Perrin Harkins</strong> - mod_perl guru and former co-worker, I really learned a lot from him about architecture, code structure, maintenance and a million other things. He's usually playing with lots of different new toys and sharing all his benchmarks and comparisons so the rest of us can make better decisions. </li><li> <strong>Jim Brandt</strong> - Current President of the Perl Foundation which means he has the hardest thankless job which everybody takes for granted in the Perl community. It's amazing how much gets done in a completely volunteer effort like the TPF and we should all be grateful for his work (and those of past presidents like Allison Randall and Richard Dice). </li></ul><p> I know I've left lots of people off this list, but the turkey needs basting, so I'll leave the rest of the thanks to other people.</p> mpeters 2009-11-26T19:17:19+00:00 journal Help needed on a new 5.10 warning http://use.perl.org/~mpeters/journal/39632?from=rss I'm trying to run an existing application on 5.10 for the first time (5.10.0 for right now) and am getting a warning that is not making it easy for me to track down. Any help from the lazy web would be appreciated.<br> <br> It goes like this:<blockquote><div><p> <tt>&nbsp; Variable "$x" is not available at (re_eval 1070) line 1.</tt></p></div> </blockquote><p>I'm assuming this is pretty deep inside some dependency I'm using (of which my application probably has an old version which doesn't play nicely with 5.10). Google is no help here as it returns a lot of CPAN testers results with the same warning for various modules (<a href="http://www.mail-archive.com/cpan-testers@perl.org/msg652326.html">http://www.mail-archive.com/cpan-testers@perl.org/msg652326.html</a>, <a href="http://trouchelle.com/perl/ppmrepview.pl?id=33577&amp;v=10">http://trouchelle.com/perl/ppmrepview.pl?id=33577&amp;v=10</a>).<br> <br> My normal trick of using</p><blockquote><div><p> <tt>&nbsp; $SIG{__WARN__} = \*Carp::cluck;</tt></p></div> </blockquote><p>to get a nice stack trace of where the warning is coming from is not actually giving me a stack trace. Anyone have any extra ideas?</p> mpeters 2009-09-15T21:48:20+00:00 journal What Perl can learn from OpenBSD http://use.perl.org/~mpeters/journal/39304?from=rss Will all the talk about trying to improve the Perl core development and release process it's interesting to see what other (non-commercially backed) open source project are doing - <a href="http://www.youtube.com/watch?v=i7pkyDUX5uM">http://www.youtube.com/watch?v=i7pkyDUX5uM</a> <br> <br> From the slashdot overview:<blockquote><div><p>Twelve years ago OpenBSD developers started engineering a release process that has resulted in quality software being delivered on a consistent 6 month schedule &#8212; 25 times in a row, exactly on the date promised, and with no critical bugs. This on-time delivery process is very different from how corporations manage their product releases and much more in tune with how volunteer driven communities are supposed to function.</p></div> </blockquote> mpeters 2009-07-17T01:05:59+00:00 journal My Slides from YAPC http://use.perl.org/~mpeters/journal/39175?from=rss Just wanted to post links to my slides from YAPC for the 2 talks I did there. Not sure how interesting they are without my accompanying tenor, but here they are: <br> <br> <a href="http://www.slideshare.net/mpeters/tap-in-depth">TAP in Depth</a> <br> <br> <a href="http://www.slideshare.net/mpeters/perl-continous-integration">Continuous Integration Testing in Perl</a> mpeters 2009-06-25T16:44:59+00:00 journal Open Source Advertising http://use.perl.org/~mpeters/journal/39112?from=rss Just saw this <a href="http://blog.reddit.com/2009/06/help-reddit-celebrate-1-year-of-open.html">announcement on reddit</a>. <br> <br> Please take a few seconds to <a href="http://www.reddit.com/r/programming/comments/8rf4b/help_reddit_celebrate_1_year_of_open_source_by/">find Perl and Parrot and upvote them</a>. And if you feel like downvoting some other projects, no one would hold that against you<nobr> <wbr></nobr>:) It's a nice way to show them that the un-dead Perl programmers can still click on links. mpeters 2009-06-10T18:27:28+00:00 journal Another perltidy lazyweb request http://use.perl.org/~mpeters/journal/39107?from=rss Having been inspired by <a href="http://use.perl.org/~domm/journal/39106">Domm</a> to fix one of my perltidy annoyances (it says something about the greatness of a tool that I keep using it even though there are some annoyances...). <br> I have these<nobr> <wbr></nobr>.perltidyrc settings:<blockquote><div><p> <tt>--indent-columns=4<br>--cuddled-else<br>--nooutdent-long-quotes<br>--paren-tightness=<nobr>2<wbr></nobr> <br>--brace-tightness=2<br>--square-bracket-tightness=2</tt></p></div> </blockquote><p>And I have this code:</p><blockquote><div><p> <tt>Some::Class-&gt;create(<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; foo =&gt; 3,<br>&nbsp; &nbsp; &nbsp; &nbsp; bar =&gt; 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; baz =&gt; 1,<br>&nbsp; &nbsp; }<br>);</tt></p></div> </blockquote><p>Now I want those opening and closing tokens to be closer together and not waste so much vertical space. So I added this:</p><blockquote><div><p> <tt>--stack-opening-tokens<br>--stack-closing-tokens</tt></p></div> </blockquote><p>Now my code looks like this:</p><blockquote><div><p> <tt>Some::Class-&gt;create({<br>&nbsp; &nbsp; &nbsp; &nbsp; foo =&gt; 3,<br>&nbsp; &nbsp; &nbsp; &nbsp; bar =&gt; 2,<br>&nbsp; &nbsp; &nbsp; &nbsp; baz =&gt; 1,<br>});</tt></p></div> </blockquote><p>Which is fabulous except that the inner args are indented 2 levels (8 spaces) instead of just 1 (4 spaces). So how do I get this?</p><blockquote><div><p> <tt>Some::Class-&gt;create({<br>&nbsp; &nbsp; foo =&gt; 3,<br>&nbsp; &nbsp; bar =&gt; 2,<br>&nbsp; &nbsp; baz =&gt; 1,<br>});</tt></p></div> </blockquote> mpeters 2009-06-09T20:37:41+00:00 journal Article about Person duplicate data http://use.perl.org/~mpeters/journal/38838?from=rss Just thought I'd mention it since it's in another place: <a href="http://proudtouseperl.com/2009/04/dealing-with-duplicate-person-data.html">http://proudtouseperl.com/2009/04/dealing-with-duplicate-person-data.html</a> mpeters 2009-04-21T18:06:02+00:00 journal Module::Build::Smolder http://use.perl.org/~mpeters/journal/38724?from=rss <p>Building off my lastest CPAN release module (Module::Build::TAPArchive) I've just released Module::Build::Smolder. Now if you want to use Smolder in your Module::Build based projects all you need to do is use this new subclass and then you can say:</p><p> &nbsp; &nbsp; $]<nobr> <wbr></nobr>./Build smolder<nobr> <wbr></nobr>...</p><p>The "..." lets you specify which Smolder server the results are sent to and for which project, etc. Both this and Module::Build::TAPArchive are preludes to another big announcement that I was hoping to have done this morning, but looks like it will have to wait until at least later tonight.</p> mpeters 2009-03-30T13:12:45+00:00 journal Module::Build::TAPArchive http://use.perl.org/~mpeters/journal/38719?from=rss <p>TAP Archives are nice little packages of your test run that contain all the different TAP streams as well as test suite metadata. It's an easy way to store the results of a test run and then analyze them later. This is what Smolder uses but it's not specific to Smolder.</p><p>While it's easy to use TAP::Harness::Archive yourself to create your own harness it's kind of overblown for small projects. prove -a works, but sometimes you really want it as part of your standard perl Build.PL &amp;&amp;<nobr> <wbr></nobr>./Build test style of work.</p><p>Enter Module::Build::TAPArchive. Just use it instead of Module::Build in your Build.PL and then you can do</p><p> &nbsp; &nbsp; perl Build.PL &amp;&amp;<nobr> <wbr></nobr>./Build test_archive</p><p>It's not doing anything really difficult behind the scenes, it should just make life a little easier for anyone who wants to play with TAP archives.</p> mpeters 2009-03-29T13:45:57+00:00 journal eat your first cookie before asking for seconds http://use.perl.org/~mpeters/journal/38599?from=rss I like Gabor a lot and I think his work with Padre is really going to pay off in efforts to attract new blood to the Perl community, but I couldn't read the latest post on his blog without writing this response (he doesn't have comments on his blog, instead he encourages people to respond to him on their own blogs). <br> <br> You should read <a href="http://www.szabgab.com/blog/2009/03/1236271318.html">his original post</a> before continuing. <br> <br> Asking TPF to fund 2 more grant ideas when you haven't even finished the last one they gave you is just asking to be rejected. It reminds me of my 5 year old asking for more cereal when he still has half his bowl left. I'm extremely unlikely to get up and get him some more. <br> <br> I've been on the receiving end of the grant process and I know it's really hard to get motivated enough to finish those grants (the money doesn't help all that much). And in his case he admits to biting off a bit more than he can chew with the XS components. So I understand his desire to drop his current grant project. <br> <br> But he should have done that prior to applying for more grants. And even then I wouldn't blame TPF for not accepting him for the next round if he didn't finish his last. <br> <br> Like I said, Gabor is a great guy and really does good work, but I don't think he should see the rejection of his grants as a rejection of Padre by TPF. Instead look at it like they are good stewards watching over the Perl community's coffers and limited resources and being cautious with investments. mpeters 2009-03-05T20:54:09+00:00 journal LD_LIBRARY_PATH trick PART 2 http://use.perl.org/~mpeters/journal/36684?from=rss In <a href="http://use.perl.org/~mpeters/journal/36433">my last post</a> I talked about a trick with setting LD_LIBRARY_PATH in the same script that needs it. Then I ran into some problems with code being run by a <code>perl -e</code> scenario. My new solution (with some help from <a href="http://use.perl.org/~rjbs/">rjbs</a>) is actually even simpler than what I'm doing now. The downside is it's not really portable. Should work for most *nixes and I only really need it to work on Linux, so I'm good. <br> <br> The answer lies in asking<nobr> <wbr></nobr>/proc what command line options I was invoked with:<blockquote><div><blockquote><div><p> <tt>$ENV{LID_LIBRARY_PATH} = '/some/computed/path';<br>exec(split("\0", `cat<nobr> <wbr></nobr>/proc/$$/cmdline`));</tt></p></div> </blockquote></div> </blockquote> mpeters 2008-06-13T18:49:44+00:00 journal LD_LIBRARY_PATH trick http://use.perl.org/~mpeters/journal/36433?from=rss I have this problem a lot. I need to link some Perl module against some C library that is not in the standard system libs. Usually this is because it's a locally installed C thingy (like Swish-e or some payment processor API) that I don't want to pollute the system install. Plus it's nice and easy if the whole application is all bundled together. <br> <br> The easy way to do this is to set the <code>$ENV{LD_LIBRARY_PATH}</code> from your shell to point to the right place. But this is a bother, and not to mention really hard to do if you need some dynamic bits to figure out what the right path is. <br> <br> And for security reasons, programs can't set their own local version of <code>LD_LIBRARY_PATH</code> and have it be respected by the system's loader. It has to be done by the calling process (in most cases the shell). <br> <br> This little trick let's a script set it's own <code>LD_LIBRARY_PATH</code> by relaunching the same program with the same arguments as a new sub-process. Simply put a <code>BEGIN</code> block like this in your script:<blockquote><div><p> <tt>BEGIN {<br>&nbsp; &nbsp; if(! $ENV{LD_LIBRARY_PATH} ) {<br>&nbsp; &nbsp; &nbsp; &nbsp; $ENV{LD_LIBRARY_PATH} = join(':', @some_paths_I_need);<br>&nbsp; &nbsp; &nbsp; &nbsp; my $self_cmd = "$^X $0 " . join(' ', @ARGV);<br>&nbsp; &nbsp; &nbsp; &nbsp; system($self_cmd);<br>&nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; }<br>}</tt></p></div> </blockquote> mpeters 2008-05-15T23:05:53+00:00 journal Oslo QA Workshop and Smolder http://use.perl.org/~mpeters/journal/36094?from=rss <p>Smolder 1.21 has just been released thanks to the Oslo Perl QA Workshop and my<br>trip sponsored by Oslo.pm and Linpro (Linpro was an amazing host for this event. They gave us free reign of their offices for the whole weekend, free food, drinks and travel). This releases fixes several installation<br>bugs on various platforms and other small bugs. It also adds several new<br>features. The highlights are:</p><p>+ Project categories have now been replaced by the more flexible smoke report tags<br>+ TAP archives can now be downloaded through the UI for a given report<br>+ Graphs can now be done on test run duration if that info was provided in the<br>archive. This was inspired by Ovid's work on the BBC's test suite's run time.<br>+ The default DB-Platform is now SQLite instead of MySQL</p><p>See the changle log for full details.<br>http://sourceforge.net/projects/smolder</p><p>I was also pretty heavily involved in the group working on the next version of TAP. I have to say that this gave me a new appreciation for standards committees. It's really hard to balance extensibility, backwards compatability and ease of use. Especially with TAP since one of it's goals is being extremely human readable. We definitely made some progress and all of the new, slightly less readable features are completely optional so if authors don't want to use them, they don't have to. But Smolder is going to have fun with all this new information coming it's way!</p> mpeters 2008-04-07T22:02:04+00:00 journal [smolder grant] progress update http://use.perl.org/~mpeters/journal/33316?from=rss <p> I found some time this weekend to do some more work on my TPF grant to improve Smolder. I'll be doing a presentation to the Raliegh Perl Mongers on Smolder the first week of June, so I'll need to find some more time pretty soon too. Plus I'll need to definitely finish this round of work before YAPC and OSCON. </p><p> The first milestone (ditching the old XML format for plain TAP) is now feature complete (with tests of course). The accepted format is now a TAR archive containing TAP files with one YAML file with META information about the test run. To see more documentation see <a href="http://smolder.svn.sourceforge.net/viewvc/smolder/trunk/docs/upload_file_format.pod?view=markup">http://smolder.svn.sourceforge.net/viewvc/smolder/trunk/docs/upload_file_format<nobr>.<wbr></nobr> pod?view=markup</a>. </p><p> The next 2 milestones have to do with setting up a system to easily automate CPAN style distributions for automatic testing from svn, etc. I've put this off for a few days but will get to it soon. </p><p> The 4th milestone was to add project specific RSS feeds. I was originally planning on using <a href="http://search.cpan.org/perldoc?XML::RSS">XML::RSS</a>, but I've decided to go a simpler route. I don't need to parse RSS or do anything fancy other than emit XML using RSS tags. Using a template would be much easier. It also means I don't need to include the dependencies of XML::RSS inside of Smolder either, so it's that much smaller. </p><p> This milestone is now feature complete as well. That just leaves 2 left. </p> mpeters 2007-05-20T16:31:25+00:00 journal [Smolder Grant Update] more work with TAP::Parser http://use.perl.org/~mpeters/journal/33143?from=rss <p> I was a little delayed in my work this week ($work and fun stuff) because my SVK repository got really screwy and wouldn't let me push changes back for certain branches. So I took a whole lot of time troubleshooting that and then finally just deleting everything and starting my svk mirrors all over again. </p><p> After that I was able to jump right back into the gutting of the XML stuff from smolder in favor or plain ol' TAP. This went pretty smoothly and I was able to get a nice an intial implementation working, so I committed it back to the svn repo. I was a little pressed for time, so the test suite is still broken, but that shouldn't take too much time to get into order. </p><p> While working with the code that I haven't touched in a while, I noticed a lot of other areas (not related to my grant work) that could use some sprucing up too. Plus there's lot of new tricks and tips I've picked up from my work on other stuff (mostly the AJAXification of <a href="http://krang.sf.net/">Krang</a>) that would be useful for smolder to. But I guess that's the way it goes. There's always something to learn and never enough time to backport those learnings to earlier projects. </p> mpeters 2007-04-28T21:44:40+00:00 journal [Smolder Grant Update] XML = TAP http://use.perl.org/~mpeters/journal/33075?from=rss <p> After battling some sickness and a little bit of yak shaving, I've finally started work on my <a href="http://news.perl-foundation.org/2007/04/new_grant_awards.html">grant for smolder</a>. </p><p> The first deliverable is to replace the custom XML schema that I used (which was based on the internal representation of a test run used by <a href="http://search.cpan.org/~nuffin/Test-TAP-Model-0.09/lib/Test/TAP/Model.pm">Test::TAP::Model</a>. I know, I know... this was a really bad thing to do, but so it goes (and yes, Test::TAP::Model has changed their internal representation). I want to replace the XML with straight TAP, but there are a few complications. TAP doesn't currently support multiple files. Each TAP "stream" correlates to one test file and the harness keeps track of the results to show the viewer at the end. Since I want smolder users to upload 1 file per test run I need something to contain them. I could wrap all those TAP streams in some container format (YAML, JSON) but then I'm no better of than the XML route I currently have. </p><p> So I've decided that smolder will take a simple archive file (tar/tar.gz initially) which contains the various TAP files. Since we sometimes want metrics like "How long did this test run take" or "What order where these files run in" (since it doesn't have to be alphabetical) then there will also be an optional YAML (or JSON I haven't decided) file in there with this meta information. </p><p> So the first step was ripping out all the XML stuff currently in Smolder and it's reliance on Test::TAP::Model and friends. Then to replace it with a TAP parser (using <a href="http://search.cpan.org/~andya/TAP-Parser-0.51/lib/TAP/Parser.pm">TAP::Parser</a>). This is currently about half way done, and I hope to find the time to finish it this week. </p> mpeters 2007-04-23T13:50:28+00:00 journal TPF Grant for Smolder and OSCon http://use.perl.org/~mpeters/journal/32868?from=rss <p> I'm pretty excited that my TPF Grant for improving <a href="http://sourceforge.net/projects/smolder">Smolder </a> has <a href="http://news.perl-foundation.org/2007/04/new_grant_awards.html">been accepted</a>. Some of the improvements are minor, but others are pretty big. I've been watching the progress of <a href="http://search.cpan.org/~andya/TAP-Parser-0.51/lib/TAP/Parser.pm">TAP::Parser</a> with enthusiasm since it means I can get rid of the YAML/XML transport hack that Smolder currently uses to get test results into the server. Hopefully this will also give some evangelism for TAP as a nice, simple and really human readable format for testing. </p><p> The grant also comes at a good time because my proposal for OSCon this year was accepted and I'll be talking about an updated testing toolkit for web applications. So Smolder will be all nice and shiny from the grant work before the talk. Which will be a nice chance to show it off and hopefully get more people using it. </p><p> I'll be updating this journal pretty regularly as I work on this grant, so stay tuned if you're interested. </p> mpeters 2007-04-01T15:37:43+00:00 journal Smolder Slides http://use.perl.org/~mpeters/journal/31119?from=rss <p> I gave the first presentation on <a href="http://sourceforge.net/projects/smolder">smolder</a> at the first Pittsburgh Perl Workshop on Saturday. It was a nice little conference that was well worth the money (<em>and not just because it was free to speakers</em><nobr> <wbr></nobr>:) </p><p> In case others are interested and missed it, my slides are <a href="http://plusthree.com/~mpeters/smolder_presentation.pdf">found here</a>. </p> mpeters 2006-09-25T18:37:47+00:00 journal Mech and hidden fields http://use.perl.org/~mpeters/journal/29922?from=rss <p> I was writing some controller tests for an application that makes heavy use of Javascript and it bit me again that <a href="http://search.cpan.org/perldoc?WWW::Mechanize">WWW::Mechanize </a> does not allow you to set the values of hidden fields, since <a href="http://search.cpan.org/perldoc?HTML::Form">HTML::Form </a> considers them read-only. </p><p> This has always bugged since if Mech is going to be useful for testing it's almost required that you mess with hidden fields because sometimes your JS will do it, or you want to make sure you've protected yourself against elementary hacking attempts. </p><p>Anyway, I always forget how to work around this, so I'm putting it here to always remind myself. If you have a hidden input named 'rm', this is how you would make it settable for Mech:</p><blockquote><div><p> <tt>&nbsp; &nbsp; my $form = $mech-&gt;form_name('my_form');<br>&nbsp; &nbsp; $form-&gt;find_input('rm')-&gt;readonly(0);<br>&nbsp; &nbsp; $mech-&gt;set_fields(rm =&gt; 'foo');</tt></p></div> </blockquote> mpeters 2006-06-15T19:04:23+00:00 journal another IE WTF http://use.perl.org/~mpeters/journal/29696?from=rss <p>How many of you have heard of "downlevel-revealed conditional comments" in HTML. Of course you haven't. It's something that <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">Microsoft made up</a>. They look like this:</p><blockquote><div><blockquote><div><p> <tt>&nbsp; &lt;![if IE]&gt;stuff&lt;![endif]&gt;;</tt></p></div> </blockquote></div> </blockquote><p>This means that <em>stuff</em> will only show up in IE browsers &lt; 5.0. </p><p>It's bad enough that they have "downlevel-hidden conditional comments", but at least those look like normal comments. </p><blockquote><div><p> <tt>&nbsp; &nbsp;&lt;!--[if !IE gte 6]&gt;stuff&lt;![endif]--&gt;</tt></p></div> </blockquote><p>This means that <em>stuff</em> will only show up in IE 6+. While this is a great way for MS to increase their market share by encouraging markup that only works in IE, at least it doesn't break anything in other browsers since it actually is a valid comment. </p><p> <em>Why does this matter?</em> I'm currently working on a $project where the audience can be using some pretty crufty browsers. We want to provide some eye-candy to those with modern browsers and just prevent those with broken browsers from getting all those annoying JS pop-up boxes with errors. The designer decides to use "downlevel-hidden conditional comments" to hide it from IE 5 and IE(mac). This works ok until we notice that on pages with forms it's broken. That's because we were using <a href="http://search.cpan.org/perldoc?HTML::FillInForm">HTML::FillInForm</a> (one of my favorite modules) which is based on <a href="http://search.cpan.org/perldoc?HTML::Parser">HTML::Parser</a>. HTML::Parser is smart enough to recognize those funny IE comments as comments, which is helpful. However, it does not treat them any differently than any other comments. So when HTML::FillInForm is creating the final document, it reads in a comment and then outputs a comment. Sounds like the right thing to do, except this breaks those funny IE comments because they now come out looking like normal comments. </p><p>The solution? I hacked up a quick sublcass of HTML::FillInForm for the project that will do-the-right thing when it encounters those little suckers. All I had to do was override the <code>comment</code> sub. So in case anyone else needs to use it, here it is:</p><blockquote><div><blockquote><div><p> <tt>sub comment {<br>&nbsp; &nbsp; my ( $self, $text ) = @_;<br>&nbsp; &nbsp; # if it begins with '[if ' and doesn't end with '&lt;![endif]'<br>&nbsp; &nbsp; # it's a "downlevel-revealed" conditional comment (stupid IE)<br>&nbsp; &nbsp; # or<br>&nbsp; &nbsp; # if it ends with '[endif]' then it's the end of a<br>&nbsp; &nbsp; # "downlevel-revealed" conditional comment (stupid IE)<br>&nbsp; &nbsp; if(<br>&nbsp; &nbsp; &nbsp; &nbsp; (<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( index($text, '[if ') == 0 )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;&amp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( $text !~<nobr> <wbr></nobr>/&lt;!\[endif\]$/ )<br>&nbsp; &nbsp; &nbsp; &nbsp; )<br>&nbsp; &nbsp; &nbsp; &nbsp; ||<br>&nbsp; &nbsp; &nbsp; &nbsp; ( $text eq '[endif]' )<br>&nbsp; &nbsp; ) {<br>&nbsp; &nbsp; &nbsp; &nbsp; $self-&gt;{output}<nobr> <wbr></nobr>.= '&lt;!' . $text . '&gt;';<br>&nbsp; &nbsp; } else {<br>&nbsp; &nbsp; &nbsp; &nbsp; $self-&gt;{output}<nobr> <wbr></nobr>.= '&lt;!--' . $text . '--&gt;';<br>&nbsp; &nbsp; }<br>}</tt></p></div> </blockquote></div> </blockquote> mpeters 2006-05-24T16:25:59+00:00 journal That's it, I'm tired of Perl http://use.perl.org/~mpeters/journal/29176?from=rss So I'm switching to Ruby. Not only does it have <a href="http://media.rubyonrails.org/video/rails_take2_with_sound.mov">cooler</a> <a href="http://media.rubyonrails.org/video/flickr-rails-ajax.mov">videos</a> but when have you ever seen a Perl programmer with a <a href="http://www.wired.com/wired/images.html?issue=14.04&amp;topic=start&amp;img=1&amp;pg=3#">glamour shot in Wired magazine</a>. Perl is a dead-end language (the PHP croud has been saying that for years and their language <a href="http://tnx.nl/php">is awesome</a>!) and the only way I'm going to get noticed is if I switch to Ruby, but not just plain ol' Ruby. My career will be <em>On Rails</em>! <br> Look out Wired Magazine, I'm <strong>way</strong> hotter than David Hansson. mpeters 2006-04-01T14:22:40+00:00 journal More FC5 breakages http://use.perl.org/~mpeters/journal/29110?from=rss Just to continue the <a href="http://use.perl.org/~samtregar/journal/29085">issues</a> that Sam Tregar mentioned about using Fedora Core 5 , I'm adding the following: <ul> <li> <strong>OpenSSL</strong> <br> FC5 comes with version 0.9.8 which has actually been available since July of 2005. But <a href="http://search.cpan.org/perldoc?Crypt::SSLeay">Crypt::SSLeay</a> which is used all over the place will not build against 0.9.8. You can, of course patch your version using the info from <a href="http://rt.cpan.org/Public/Bug/Display.html?id=16735">here</a>. </li><li> <strong>SQLite</strong> <br> FC5 comes with version 3.3.3 which is isn't even the latest stable version (3.3.4 is). But <a href="http://search.cpan.org/perldoc?DBD::SQLite">DBD::SQLite</a> won't build against it. There is a work around, because <a href="http://search.cpan.org/perldoc?DBD::SQLite">DBD::SQLite</a> comes with it's own version (3.2.7) of SQLite and uses it if you don't already have one installed. Or you can force it to use it anyway by running Makefile.PL like so<blockquote><div><p> <code>perl Makefile.PL USE_LOCAL_SQLITE=1</code></p></div> </blockquote></li></ul><p> If I notice anything else I'll be sure to let you know.</p> mpeters 2006-03-26T22:30:56+00:00 journal HTML Form filling benchmarks http://use.perl.org/~mpeters/journal/28943?from=rss Every web application needs to fill in HTML &lt;form&gt;s at some point. Simple text &lt;input&gt;s and &lt;textarea&gt;s are easy to do. But radio buttons, checkboxes and &lt;select&gt;s are a bit harder. <br> <br> I love <a href="http://search.cpan.org/perldoc?HTML::FillInForm">HTML::FillInForm</a> because each form &lt;input&gt; is treated the same. It doesn't matter if the designer wants to change from a &lt;select&gt; box to radio boxes, or replace it with a text &lt;input&gt;. The code that fills it doesn't change. <br> <br> But HTML::FillInForm has to parse the entire HTML, find the &lt;form&gt; and the inputs and then change the HTML to include all the values and <code>selected="selected"</code> stuff. That's gotta be slow, right?<br> <br> So, to see how slow I decided to benchmark it (against <a href="http://search.cpan.org/perldoc?HTML::Template::Expr">HTML::Template::Expr</a>). Here's the results (<em>code benchmarked is at the bottom</em>):<br> With small, fairly simple forms, and using external files so H::T::E could cache -<blockquote><div><p> <tt>For 1000 iterations:<br> <br>&nbsp; &nbsp; &nbsp; Rate hte fif<br>hte 1493/s&nbsp; -- -7%<br>fif 1613/s&nbsp; 8%&nbsp; --<br> <br>&nbsp; &nbsp; &nbsp; Rate&nbsp; fif&nbsp; hte<br>fif 1075/s&nbsp; &nbsp;-- -11%<br>hte 1205/s&nbsp; 12%&nbsp; &nbsp;--</tt></p></div> </blockquote><p>And it usually went back and forth like that. They were both very close and the winner flipped-flopped.<br> <br> Now with a very large complicated HTML with lots of other markup taken straight from a client's site:</p><blockquote><div><p> <tt>[mpeters@localhost ~]$<nobr> <wbr></nobr>./bench.pl<br>&nbsp; &nbsp; &nbsp; Rate&nbsp; hte&nbsp; fif<br>hte 44.2/s&nbsp; &nbsp;-- -27%<br>fif 60.6/s&nbsp; 37%&nbsp; &nbsp;--<br>[mpeters@localhost ~]$<nobr> <wbr></nobr>./bench.pl<br>&nbsp; &nbsp; &nbsp; Rate&nbsp; hte&nbsp; fif<br>hte 41.8/s&nbsp; &nbsp;-- -36%<br>fif 65.4/s&nbsp; 56%&nbsp; &nbsp;--</tt></p></div> </blockquote><p>FillInForm consistently beat H::T::E on this large form. I was pretty amazed. If you see any problems with my benchmark, please let me know. <br> <br> <strong>Benchmark code</strong> </p><blockquote><div><p> <tt>#!/usr/bin/perl<br>use strict;<br>use warnings;<br>use Benchmark qw(:all);<br>use HTML::FillInForm;<br>use HTML::Template::Expr;<br>use HTML::Template;<br> <br>my %values = (<br>&nbsp; &nbsp; prefix&nbsp; &nbsp; &nbsp; =&gt; 'Mr.',<br>&nbsp; &nbsp; first_name&nbsp; =&gt; 'Michael',<br>&nbsp; &nbsp; last_name&nbsp; &nbsp;=&gt; 'Peters',<br>&nbsp; &nbsp; address1&nbsp; &nbsp; =&gt; '1234 Main St.',<br>&nbsp; &nbsp; city&nbsp; &nbsp; &nbsp; &nbsp; =&gt; 'Silver Spring',<br>&nbsp; &nbsp; state&nbsp; &nbsp; &nbsp; &nbsp;=&gt; 'Maryland',<br>&nbsp; &nbsp; zip&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; '12345',<br>&nbsp; &nbsp; country&nbsp; &nbsp; &nbsp;=&gt; 'US',<br>);<br> <br>sub fill_form {<br>&nbsp; &nbsp; my $tmpl = HTML::Template-&gt;new(<br>&nbsp; &nbsp; &nbsp; &nbsp; filename =&gt; 'form_text.tmpl',<br>&nbsp; &nbsp; &nbsp; &nbsp; cache&nbsp; &nbsp; =&gt; 1,<br>&nbsp; &nbsp; );<br>&nbsp; &nbsp; my $out = $tmpl-&gt;output();<br> <br>&nbsp; &nbsp; HTML::FillInForm-&gt;new()-&gt;fill(<br>&nbsp; &nbsp; &nbsp; &nbsp; scalarref =&gt; \$out,<br>&nbsp; &nbsp; &nbsp; &nbsp; fdat&nbsp; &nbsp; &nbsp; =&gt; \%values,<br>&nbsp; &nbsp; );<br>}<br> <br>sub fill_tmpl {<br>&nbsp; &nbsp; my $tmpl = HTML::Template::Expr-&gt;new(<br>&nbsp; &nbsp; &nbsp; &nbsp; filename =&gt; 'tmpl_text.tmpl',<br>&nbsp; &nbsp; &nbsp; &nbsp; cache&nbsp; &nbsp; =&gt; 1,<br>&nbsp; &nbsp; );<br>&nbsp; &nbsp; $tmpl-&gt;param(%values);<br>&nbsp; &nbsp; $tmpl-&gt;output();<br>}<br> <br>cmpthese(<br>&nbsp; &nbsp; 1000,<br>&nbsp; &nbsp; {<br>&nbsp; &nbsp; &nbsp; &nbsp; hte =&gt; sub { fill_tmpl() },<br>&nbsp; &nbsp; &nbsp; &nbsp; fif =&gt; sub { fill_form() },<br>&nbsp; &nbsp; },<br>);</tt></p></div> </blockquote> mpeters 2006-03-09T21:40:05+00:00 journal where there's smoke.... http://use.perl.org/~mpeters/journal/28874?from=rss In my last big project we had a nice, large test suite and the team was really good about always running it before most commits. But there were always problems with things that passed on one developer's machine and not the others (usually becuase of some files or changes that were not checked in). So I setup an automated smoke test that ran every night and emailed the results to the developers. I even made it nice and pretty using <a href="http://search.cpan.org/perldoc?Test::TAP::HTMLMatrix">Test::TAP::HTMLMatrix</a> (mentioned here - <a href="http://use.perl.org/~mpeters/journal/25612">http://use.perl.org/~mpeters/journal/25612</a>). This worked pretty well, but as always, it could be improved. These are some areas that needed improvement: <ol> <li>It sent emails whether the test suite passed or not. While I like this (it let me know that the automated tests were still running) other developers just wanted to see the report when tests failed</li><li>The report could be very, very large <em>(5000+ tests and over 500k of HTML)</em>.</li><li>There wasn't an easy way for developers to share test reports between themselves without pasting large chunks of test output into emails</li><li>It was very tied to that specific project</li></ol><p> This is why <a href="https://sourceforge.net/projects/smolder">Smolder</a> was born. It solves the above problems in the following ways </p><ol> <li>Developers choose when they want to receive emails. Either a) All the time b) just when there are failures, or even c) never.</li><li>Developers can also choose what format their email comes in. It can either be the full HTML, or just a summary, or even just a link to the full report. Smolder contains the full report so it can always be viewed at any time.</li><li>Test reports can be uploaded by either an autormated test setup, or individually by developers (in either XML or YAML using either <a href="http://search.cpan.org/perldoc?Test::TAP::XML">Test::TAP::XML </a>or <a href="http://search.cpan.org/perldoc?YAML">YAML</a> + <a href="http://search.cpan.org/perldoc?Test::TAP::Model">Test::TAP::Model</a>)</li><li>It's a standalone server that's project agnostic. Plus one smolder install can host several projects. The only thing that needs to be adjusted for each project is to add Test::TAP::XML to the test harness.</li></ol><p> <a href="https://sourceforge.net/project/screenshots.php?group_id=161136">Screen shots</a> are available if you want to see it (just to make sure it's not too ugly).<br> <br> Please try it out, give some feedback and request features. It's just at version 0.01 so it's future is very flexible.</p> mpeters 2006-03-04T19:02:45+00:00 journal Open source and automobiles http://use.perl.org/~mpeters/journal/27859?from=rss Since most of my friends and family are not associated with software (except for my dad) and are almost completely ignorant of OSS, I feel compelled to explain my views to them in a way that doesn't completely bore them. For some reason, most of my explanations and analogies involve cars. It's not because I'm particularly interested in cars; but when I tried to find an example of other people who like to tinker, sometimes as a hobby, sometimes as a profession, the first thing that came to mind was a mechanic. <br> <br> So I thought I'd share these examples here and maybe others will find them useful. <ul> <li> <strong>Red Cars and Firefox:</strong> <br> It has been reported that red is the most popular color for stolen cars. Are red cars any more insecure than white cars? When comparing Internet Explorer and Firefox, MS fans defend IE by saying it is more targeted by viruses and spyware because it's more popular. Even if Firefox isn't any more secure than Internet Explorer, isn't choosing a white car over a red one a good idea just because it won't be as big of a target? I think so.</li><li> <strong>Tweak out your engine and I'll sue you</strong><blockquote><div><p> <em>Why should I care if I don't get the code when I buy software? I'll never look at it or change it?</em></p></div> </blockquote><p> It's true that most people buy their cars and have no interest in ever even opening the hood. And most of those that do will only change their oil, or replace belts, etc. Very few will ever replace their alternators or rebuild their engine. <em>But some will.</em> <br> <br> While most people don't care to get their hands that dirty, how would people react if Ford suddenly sold all of their cars with the hoods locked such that only an authorized dealer could open it? (And in a comparison to some companies, threaten legal action if you figure out a way to open it yourself). If they decided that you cannot get any repairs (patches or upgrades) from anyone except the dealership? I'm sure they'd love the extra revenue, but the business they would lose would greatly offset that. The public outrage caused by such a business decision would be quite significant.<br> <br> Why shouldn't you be allowed to tinker under the hood of the software you buy? Even if you don't want to, shouldn't you be allowed to take it to another professional who would be experienced enough to do it for you?</p> </li></ul> mpeters 2005-12-05T02:19:56+00:00 journal Flowcharts... Evil, evil, evil! http://use.perl.org/~mpeters/journal/26892?from=rss I'm in the final phases of a project that has been going on for some time. We have extensive documentation in all modules and scripts and several POD files filled with details and overviews of various sections and how the pieces fit together (141 pages of HTML with indeces, and nicely linked together).<br> <br> Now we are getting ready to hand the code over to the $client's internal developers and we have asked them to peruse the docs to let us know if there is anything lacking. They (actually just one person) gave us a list of several things (most of which were there so it makes me think they didn't even look at it) that they want, most notably flow charts that show every control module (we're using MVC), every run mode (using CGI::Application), every template and every hyperlink (or form submission) between them.<br> <br> I have a problem with this. Flowcharts are nice when used to gather requirements but quickly become stale if you do any kind of iterative development and I hate maintaining documentation that is separate from code. So I've been pushing back on this. <br> <br> As it just happens I've been reading "The Mythical Man-Month" and just came across a great section on flowcharts. <em>(written by Frederick P. Brooks, JR. in 1975)</em><blockquote><div><p>The detailed blow-by-blow flow chart, however, is an obsolete nuisance, suitable only for initiating beginners into algorithmic thinking.</p></div> </blockquote><p> Speaking of the fact that know one keeps good up-to-date flowcharts, he said:</p><blockquote><div><p>I think this universal experience is not an embarrassing and deplorable departure from good practice, to be ackknowledged only with a nervous laugh. Instead it is the application of good judgement, and it it teaches us something about the utility of flow charts. <br>...<br> A basic principle of data processing teaches the folly of trying to maintain independent files in synchronism...Yet our practice in programming documentation violates our own teaching.</p></div> </blockquote> mpeters 2005-09-26T18:54:16+00:00 journal Perty Testing Harness http://use.perl.org/~mpeters/journal/25612?from=rss So I'm working on this web project that has a custom test harness and nightly automated tests. Right now it runs the tests using Test::Harness, captures the output and then emails it to everyone on the mailing list for the project. It's worked really well so far, but the output is kinda plain and because there are 96 test files, and 3000+ individual tests the test output is a little hard to <em>skim</em> quickly in the morning to make sure everything worked...<br> <br> Enter <a href="http://search.cpan.org/perldoc?Test::TAP::HTMLMatrix">Test::TAP::HTMLMatrix</a>. <br> <br> This module will run the desired tests, record the output from any <a href="http://search.cpan.org/perldoc?Test::Harness::TAP">TAP </a> compatible tests (eg, anything using Test or Test::More, etc) and then format them into nice, pretty and colorful HTML results.<br> <br> So I decided to try and capture this out and send out a multipart email using <a href="http://search.cpan.org/perldoc?MIME::Lite">MIME::Lite</a>. And the code looked something like this:<blockquote><div><p> <tt>&nbsp; # create the TAP model to run and capture the<br>&nbsp; # TAP test output<br>&nbsp; my $model = Test::TAP::Model::Visual-&gt;new();<br>&nbsp; $model-&gt;run_tests(@testfiles);<br> <br>&nbsp; # now get the HTML output<br>&nbsp; my $matrix = Test::TAP::HTMLMatrix-&gt;new($model);<br>&nbsp; my $output = $matrix-&gt;html();<br> <br>&nbsp; # now send it in an email<br>&nbsp; my $msg = MIME::Lite-&gt;new(<br>&nbsp; &nbsp; From&nbsp; &nbsp; =&gt; 'testing@plusthree.com',<br>&nbsp; &nbsp; To&nbsp; &nbsp; &nbsp; =&gt; 'project_list@plusthree.com,<br>&nbsp; &nbsp; Subject =&gt; 'Automated Test - ' . scalar(localtime),<br>&nbsp; &nbsp; Type&nbsp; &nbsp; =&gt; 'multipart/alternative',<br>&nbsp; );<br>&nbsp; $msg-&gt;attach(<br>&nbsp; &nbsp; Type =&gt; 'text/html',<br>&nbsp; &nbsp; Data =&gt; $email_output,<br>&nbsp; );<br>&nbsp; $msg-&gt;send()</tt></p></div> </blockquote><p>Pretty simple huh? But darn cool.</p> mpeters 2005-07-10T00:32:56+00:00 journal