<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Jabbering Giraffe &#187; perl</title>
	<atom:link href="http://happygiraffe.net/blog/tag/perl/feed/rss2/" rel="self" type="application/rss+xml" />
	<link>http://happygiraffe.net/blog</link>
	<description></description>
	<pubDate>Wed, 20 Aug 2008 00:45:12 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>for() $DEITY&#8217;s sake, why?</title>
		<link>http://happygiraffe.net/blog/2008/04/02/for-deitys-sake-why/</link>
		<comments>http://happygiraffe.net/blog/2008/04/02/for-deitys-sake-why/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 10:17:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article12970</guid>
		<description><![CDATA[I used to think I had a reasonable grasp of Perl.  Yesterday, I realised I didn&#8217;t even understand a basic foreach loop.

  my $val;
  my @values = qw( a b c );
  foreach $val (@values) {
    print $val, "\n";
  }
  print "[end] $val\n";

I reckoned that this [...]]]></description>
			<content:encoded><![CDATA[<p>I used to think I had a reasonable grasp of Perl.  Yesterday, I realised I didn&#8217;t even understand a basic foreach loop.</p>
<pre>
  my $val;
  my @values = qw( a b c );
  foreach $val (@values) {
    print $val, "\n";
  }
  print "[end] $val\n";
</pre>
<p>I reckoned that this should print:</p>
<pre>
  a
  b
  c
  [end] c
</pre>
<p>Instead, it prints:</p>
<pre>
  a
  b
  c
  Use of uninitialized value in concatenation (.) or string at foo.pl line 11.
  [end]
</pre>
<p>This confused me no end.  But it&#8217;s actually documented behaviour.  From <a href="http://perldoc.perl.org/perlsyn.html#Foreach-Loops">perlsyn</a></p>
<blockquote>
<p>The foreach loop iterates over a normal list value and sets the variable <span class="caps">VAR</span> to be each element of the list in turn. If the variable is preceded with the keyword my, then it is lexically scoped, and is therefore visible only within the loop. Otherwise, the variable is implicitly local to the loop and regains its former value upon exiting the loop. <em>If the variable was previously declared with my, it uses that variable instead of the global one, but it&#8217;s still localized to the loop</em>. This implicit localisation occurs only in a foreach loop.</p>
</blockquote>
<p>Wow.  You really do learn something new every day.  I suspect that this is implementation behaviour that was documented post-fact, rather than designed that way.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2008/04/02/for-deitys-sake-why/feed/</wfw:commentRss>
		</item>
		<item>
		<title>London Perl Workshop 2006</title>
		<link>http://happygiraffe.net/blog/2006/12/10/london-perl-workshop-2006/</link>
		<comments>http://happygiraffe.net/blog/2006/12/10/london-perl-workshop-2006/#comments</comments>
		<pubDate>Sun, 10 Dec 2006 16:05:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[london]]></category>

		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article8909</guid>
		<description><![CDATA[Yesterday was the London Perl Workshop, a one-day, two-track conference put together by the London Perl Mongers (in particular, muttley and Greg).  I arrived early (mostly due to my lack of faith in train times), so got to put up posters first.
First talk of the day was Jesse Vincent on Jifty, the web application [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday was the <a href="http://london.pm.org/lpw/">London Perl Workshop</a>, a one-day, two-track conference put together by the <a href="http://london.pm.org/">London Perl Mongers</a> (in particular, <a href="http://www.thegestalt.org/simon/">muttley</a> and <a href="http://drinkbroken.typepad.com/">Greg</a>).  I arrived early (mostly due to my lack of faith in train times), so got to put up posters first.</p>
<p>First talk of the day was <a href="http://use.perl.org/~jesse/journal/">Jesse Vincent</a> on <a href="http://jifty.org/">Jifty</a>, the web application framework originating from within <a href="http://bestpractical.com/">Best Practical</a>.  It was a basic introduction&#8212;making blog software, of course.  Jesse took us through the details quite quickly, but it was immediately clear that very little work needs to be done for a basic <a href="http://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete"><span class="caps">CRUD</span></a> app.  It appears to use <a href="http://www.masonhq.com/">Mason</a> by default, which I consider a plus point.  Overall it felt very railsish, particularly the fact that it has <a href="http://weblog.jamisbuck.org/2005/9/27/getting-started-with-activerecord-migrations">migrations</a>.  I <em>love</em> migrations.</p>
<p>After the basic intro, he went over a few advanced features like the continuations support (of which more later) and the developer support.  There&#8217;s a bunch of stuff in there that I really need to look at nicking for work, like the builtin Mason profiler support and the inline fragment editing, not to mentioned <a href="http://search.cpan.org/dist/CSS-Squish/"><span class="caps">CSS</span>::Squish</a> and <a href="http://search.cpan.org/dist/JavaScript-Squish/">JS::Squish</a>.</p>
<p>On the whole, I&#8217;m not sure about Jifty.  It looks lovely, and quick to develop in.  But that amount of concentrated magic scares me.  I need to try out a couple of small applications to get a better feel for it.</p>
<p>I stayed on for the next talk, Mike Astle on <a href="http://www.wigwam-framework.org/index.html">wigwam</a> (a deployment tool).  I&#8217;m interested in doing deployment better, but ultimately, wigwam didn&#8217;t seem to offer that much more than what I have at the moment: a way of building packages into a compartmentalised space that can be distributed around different servers.  Looking around the audience in the question time, I think I wasn&#8217;t alone.</p>
<p>Afterwards, I popped down to see <a href="http://people.freebsd.org/~tom/">Tom Hukins</a> talk on &#8220;Just in time testing&#8221;.  Sadly, <a href="http://use.perl.org/~tomhukins/journal/31866">Tom was ill</a>.  However, <a href="http://use.perl.org/~Abigail/journal/">abigail</a> stepped up and offered to talk about <a href="http://perldoc.perl.org/Benchmark.html">Benchmark.pm</a> instead, highlighting the many ways in which it can be abused.  He had culled a number of uses of Benchmark from perlmonks, and demonstrated various flaws.  Such as not benchmarking the same thing, or trying to benchmark volatile data.  The best was when he demonstrated how the compiler had completely optimised away one of the branches.  Naturally executing a statement which has been optimised away is very quick.</p>
<p>My main beef with all of this was simply that the things being benchmarked were phenomenally simple.  Really, if you care about map vs grep performance, go write it in C.  Otherwise, profile your app long before you start to think about these things.  <a href="http://perlmonks.org/index.pl?node_id=108447">demerphq</a> pointed out that you can end up dieing the death of a thousand cuts if you don&#8217;t care about some of these little things, however.</p>
<p>Funnily enough, demerphq was speaking next on the changes to the regex engine coming up in Perl 5.10.  This was a really deep, informative talk, and I&#8217;ll admit to glossing over some parts of it, but there were two things that really stuck out for me:</p>
<ul>
<li>Recursive patterns.  This makes it really easy to call back into the regex you&#8217;re matching.  This is very handy for doing things like matching balanced tags correctly.</li>
<li>Named parameter groups.  Nicked from .Net and Python.  This should make large regexes much simpler.</li>
</ul>
<p>Apart from that, there&#8217;s been a whole lot of work to optimize the regex engine, as well as making it properly pluggable.  This now leads to the situation of making <a href="http://www.pcre.org/"><span class="caps">PCRE</span></a> <em>truly</em> Perl compatible by embedding it&#8230;</p>
<p>After lunch, I listened to Jesse Vincent again, on &#8220;Advanced Jifty&#8221;.  This was basically peeking inside some of the deep magic that&#8217;s going on in there.  First, Jesse gave an overview of the message bus inside Jifty.  The heart of it is <a href="http://search.cpan.org/dist/IPC-PubSub/"><span class="caps">IPC</span>::PubSub</a>.  Moving on, he peeked inside <a href="http://search.cpan.org/~jesse/Template-Declare--1.00_01/lib/Template/Declare.pm">Template::Declare</a>.  This is a bit like <a href="http://markaby.rubyforge.org/">markaby</a>.  Jesse pointed out a couple of &#8220;unusual&#8221; implementation details such as <code>local *__ANON__ = $tag;</code> which is an undocumented way of naming auto-generated subroutines so that stack traces make sense.  He also presented a quote from Audrey: &#8220;we read every bit of perlsub.pod and abused it all&#8221;.</p>
<p>Lastly he covered the <a href="http://search.cpan.org/~autrijus/i18n-0.07/lib/i18n.pm">i18n</a> pragma, which is just filled with scary magic to make <code>~~'hello world'</code> look up hello world in a message catalog and return a translated version.  There&#8217;s a great deal of use of <a href="http://perldoc.perl.org/overload.html">overload</a> and <a href="http://perldoc.perl.org/overload.html#Overloading-constants">overload::constant</a>.</p>
<p>A this point, Jesse started to run out of time, so he rushed through a few other interesting uses of Perl:</p>
<ul>
<li>Using a function called <code>_</code>, which is globally available in all packages.</li>
<li>Blessing into a class called <code>0</code> in order to return false from <a href="http://perldoc.perl.org/functions/ref.html">ref</a>.</li>
<li>Creating an <span class="caps">MD5</span> sum of the call stack.  I&#8217;m guessing that&#8217;s how they implement continuations support.</li>
</ul>
<p>From one mind boggling talk to another: Abigail was on next, with &#8220;Sudoku by regex&#8221;.  I won&#8217;t begin to pretend to understand what it was all about, except to note that a standard 9&#215;9 Sudoku grid took 1.5 hours to solve in a single regex.  Apparently, he&#8217;s also been trying out other games in a similar fashion, except that one of them he let run for 2 weeks before pressing <code>^C</code>&#8230;</p>
<p>Alistair McGlinchy talked about &#8220;How to make a grumpy network capacity planner happy&#8221;.  This was a really nice little piece on what his work as a network admin involves, and why developers chew up lots of bandwith without thinking.  He gave a really good overview of <span class="caps">HTTP</span> caching / compression, which needs to be more widely known.</p>
<p>Ash Berlin spoke on <a href="http://trac.jrock.us/blog_software">Angerwhale</a>, which is a blog that doesn&#8217;t use a database, but does use <a href="http://www.catalystframework.org/">Catalyst</a>.  Consensus from my bit of the audience: why aren&#8217;t you using <a href="http://www.blosxom.com/">bloxsom</a>?  It&#8217;s smaller, simpler and works just as well.</p>
<p>Finally, <a href="http://search.cpan.org/~kane/">Jos Boumans</a> gave his <em>superb</em> talk on barely legal <span class="caps">XXX</span> Perl.  It&#8217;s a detailed blow by blow account of making <a href="http://search.cpan.org/~adamk/Acme-BadExample-1.00/lib/Acme/BadExample.pm">Acme::BadExample</a> run, despite all the deviousness contained therein.  As with Jesse&#8217;s talk, this is scary stuff, but gives a real insight into how to mold Perl to your will.</p>
<p>All in all, a superb day.  Interesting people, interesting talks.  It was well organised.  I&#8217;m extremely grateful that it was put on, particularly for free thanks to the sponsors&#8230;</p>
<p>Anyway, after the conference, the only natural thing to do was retreat to another pub.  I only spent a short while there before departing for the <a href="http://backstage.bbc.co.uk/news/archives/2006/12/bbc_backstage_l_2.html"><span class="caps">BBC</span> Backstage Xmas bash</a>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/12/10/london-perl-workshop-2006/feed/</wfw:commentRss>
		</item>
		<item>
		<title>XML::Genx 0.22</title>
		<link>http://happygiraffe.net/blog/2006/10/08/xml-genx-0-22/</link>
		<comments>http://happygiraffe.net/blog/2006/10/08/xml-genx-0-22/#comments</comments>
		<pubDate>Sun, 08 Oct 2006 19:18:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[cpan]]></category>

		<category><![CDATA[genx]]></category>

		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article1112</guid>
		<description><![CDATA[I&#8217;ve released XML::Genx 0.22.  There are no functional changes, just a couple of minor bugfixes in order to ensure that it works on Windows correctly.
For some time now, I&#8217;d been trying to get XS modules compiling on Windows correctly under ActiveState Perl, all to no avail.  But now, thanks to the wonder of [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released <a href="http://search.cpan.org/~hdm/XML-Genx-0.22/"><span class="caps">XML</span>::Genx 0.22</a>.  There are no functional changes, just a couple of minor bugfixes in order to ensure that it works on Windows correctly.</p>
<p>For some time now, I&#8217;d been trying to get XS modules compiling on Windows correctly under ActiveState Perl, all to no avail.  But now, thanks to the wonder of <a href="http://win32.perl.org/wiki/index.php?title=Strawberry_Perl">Strawberry Perl</a>, I&#8217;ve actually been able to build and test the module all on my own.  I am hugely grateful to the authors for putting together Strawberry Perl.  It&#8217;s a huge boon for developing Perl on Windows (Not that I diss ActiveState; they&#8217;ve also done a good job, but they&#8217;ve gone in different directions).</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/10/08/xml-genx-0-22/feed/</wfw:commentRss>
		</item>
		<item>
		<title>subatom 0.11</title>
		<link>http://happygiraffe.net/blog/2006/09/27/subatom-0-11/</link>
		<comments>http://happygiraffe.net/blog/2006/09/27/subatom-0-11/#comments</comments>
		<pubDate>Wed, 27 Sep 2006 14:43:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[cpan]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[subatom]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article1089</guid>
		<description><![CDATA[Yet another new version, subatom 0.11 again prompted by Hans F. Nordhaug.  The only change this time is to add a feed_title option to the config file, so you can specify the title for the feed as a whole.
Now, I&#8217;m going to sit down and attempt to rework all this as a module+script, along [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another new version, <a href="http://search.cpan.org/~hdm/subatom-0.11/">subatom 0.11</a> again prompted by <a href="http://home.himolde.no/~nordhaug/english.php">Hans F. Nordhaug</a>.  The only change this time is to add a <em>feed_title</em> option to the config file, so you can specify the title for the feed as a whole.</p>
<p>Now, I&#8217;m going to sit down and attempt to rework all this as a module+script, along with some tests.  That I managed to break things in the 0.09 release was very irritating, and the tests should have caught that.</p>
<p><strong>Update</strong>: Please grab <a href="http://search.cpan.org/~hdm/subatom-0.12/">subatom 0.12</a> instead when it shows up if you want a working version.  Doh.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/09/27/subatom-0-11/feed/</wfw:commentRss>
		</item>
		<item>
		<title>subatom 0.10</title>
		<link>http://happygiraffe.net/blog/2006/09/26/subatom-0-10/</link>
		<comments>http://happygiraffe.net/blog/2006/09/26/subatom-0-10/#comments</comments>
		<pubDate>Tue, 26 Sep 2006 10:19:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[cpan]]></category>

		<category><![CDATA[locales]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[subatom]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article1087</guid>
		<description><![CDATA[I&#8217;ve made another release of subatom.  This contains a number of fixes for bugs that I managed to put into the 0.09 release (as well as a couple of minor features).  This has really left me with a very nagging need for some tests for this module.

Restore the ability to send output to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made another release of subatom.  This contains a number of fixes for bugs that I managed to put into the 0.09 release (as well as a couple of minor features).  This has really left me with a very nagging need for some tests for this module.</p>
<ul>
<li>Restore the ability to send output to stdout.</li>
<li>Make the command line mode work, as well as the config file.</li>
<li>Don&#8217;t cover up stderr when executing &#8220;svn log&#8221;.</li>
<li>Force subversion to give us back <span class="caps">UTF</span>-8, and cope with it.</li>
<li>Add support for using&#8212;limit if your svn has it.</li>
</ul>
<p>That item about <span class="caps">UTF</span>-8 has annoyed me, because it&#8217;s brought me into contact with a hated topic: locales.</p>
<p>Subversion internally works with <span class="caps">UTF</span>-8 everywhere.  This is a sensible design.  But in order to interface with the outside world, it needs to convert that into whatever character encoding you are using.  How does it know what character encoding to use?  It guesses from the locale.</p>
<p>The locale is <em>meant</em> to be a specification for how to sort characters, how to format the date and so on and so forth.  In recent years, it&#8217;s also been taken over to specify the character encoding that&#8217;s in use.  So, to specify that I want to see the world in <span class="caps">UTF</span>-8, I need to say:</p>
<pre>
  export LC_ALL=en_GB.UTF-8
</pre>
<p>Except that breaks ls(1).  Yes, ls(1).  For some <em>insane</em> reason, setting a locale changes the way that things work such sorting now happens in a case-independent manner.  So that &#8220;README&#8221; files no longer appear at the top of a directory listing.  I haven&#8217;t investigated any further to see what else is broken.  I quickly switched back to the &#8220;C&#8221; locale, which effectively means no locale.</p>
<p>So now, I&#8217;m left wondering how to tell the system that I&#8217;d like <span class="caps">UTF</span>-8, but none of the other inconveniences that locales bring me.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/09/26/subatom-0-10/feed/</wfw:commentRss>
		</item>
		<item>
		<title>subatom 0.09</title>
		<link>http://happygiraffe.net/blog/2006/09/25/subatom-0-09/</link>
		<comments>http://happygiraffe.net/blog/2006/09/25/subatom-0-09/#comments</comments>
		<pubDate>Mon, 25 Sep 2006 10:53:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[cpan]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[subatom]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article1082</guid>
		<description><![CDATA[I&#8217;ve released a new version of my tool subatom.  If you haven&#8217;t seen it, it produces atom feeds for subversion commit messages.  It&#8217;s pretty handy for monitoring activity in a subversion repository and it doesn&#8217;t need access to the server.
There are only two new features in this release:

Add in a option to specify [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released a new version of my tool <a href="http://search.cpan.org/dist/subatom/">subatom</a>.  If you haven&#8217;t seen it, it produces atom feeds for subversion commit messages.  It&#8217;s pretty handy for monitoring activity in a subversion repository and it doesn&#8217;t need access to the server.</p>
<p>There are only two new features in this release:</p>
<ul>
<li>Add in a option to specify <code>link[@rel="self"]</code>, which means that the generated feeds can now pass the <a href="http://feedvalidator.org/">feedvalidator</a> with flying colours.  Many thanks to <a href="http://home.himolde.no/~nordhaug/english.php">Hans F. Nordhaug</a> for the patch.</li>
<li>I&#8217;ve added in a config file.  I broke down and did it because I&#8217;d ended up with scripts that just called subatom in a variety of ungainly ways.  Using a config file makes things slightly more manageable.</li>
</ul>
<p>However, as with all releases, there are already a couple of problems:</p>
<ul>
<li>Hans found that it doesn&#8217;t really cope with character encodings properly.  This is particularly shameful for me.  So I&#8217;ll take a peek at it tonight to ensure that we tell subversion to give us <span class="caps">UTF</span>-8 and process that accordingly.</li>
<li>Another point brought up by Hans is that it should invoke <code>svn log</code> as <code>svn log --limit</code>.  I&#8217;d been avoiding that because I&#8217;m still on an older version of svn at work, but there&#8217;s no reason to not run <code>svn help log</code> and check the output to see if <code>--limit</code> is available.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/09/25/subatom-0-09/feed/</wfw:commentRss>
		</item>
		<item>
		<title>gdb ruby $pid</title>
		<link>http://happygiraffe.net/blog/2006/09/22/gdb-ruby-pid/</link>
		<comments>http://happygiraffe.net/blog/2006/09/22/gdb-ruby-pid/#comments</comments>
		<pubDate>Fri, 22 Sep 2006 22:14:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[gdb]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article1081</guid>
		<description><![CDATA[gdb is my &#8220;tool of last resort&#8221;.  When all other online diagnostics have failed, I know enough gdb to pull out a C level stack trace.

  % gdb $SHELL $$
  GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:06:22 GMT 2006)
  /Users/dom/320: No such file or directory.
  Attaching to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gnu.org/software/gdb/">gdb</a> is my &#8220;tool of last resort&#8221;.  When all other online diagnostics have failed, I know enough gdb to pull out a C level stack trace.</p>
<pre>
  % gdb $SHELL $$
  GNU gdb 6.3.50-20050815 (Apple version gdb-477) (Sun Apr 30 20:06:22 GMT 2006)
  /Users/dom/320: No such file or directory.
  Attaching to program: `/bin/zsh', process 320.
  Reading symbols for shared libraries ........ done
  0x90006108 in syscall ()
  (gdb) where
  #0  0x90006108 in syscall ()
  #1  0x00054558 in signal_suspend ()
  #2  0x0002c9a8 in waitforpid ()
  #3  0x0002cb4c in waitjobs ()
  #4  0x00012584 in execlist ()
  #5  0x00011c24 in execlist ()
  #6  0x00011874 in execode ()
  #7  0x00026890 in loop ()
  #8  0x0002945c in zsh_main ()
  #9  0x00001d14 in start ()
</pre>
<p>It&#8217;s not terribly informative, but in the past, it&#8217;s given me <em>just enough</em> of a clue to start looking at the <span class="caps">SSL</span> libraries (for example).</p>
<p>Jamis Buck has gone one better&#8212;he&#8217;s pulled a <a href="http://weblog.jamisbuck.org/2006/9/22/inspecting-a-live-ruby-process/">ruby stacktrace from a running process</a>.  Which seems quite magical to me indeed.  I also think that you can turn most of what he&#8217;s done into a gdb macro.  I&#8217;ll have to have a look at <a href="http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/debugscripts/">some examples</a>&#8230;</p>
<p>In the past, I&#8217;ve resorted installing a signal handler &#8220;just in case&#8221; to pull out this sort of information.  All of my Perl apps have this in their startup files.</p>
<pre>
  $SIG{ USR2 } = sub { Carp::cluck("Caught SIGUSR2 in $$") };
</pre>
<p>Which is all very well, <em>if</em> you know what you need in advance.  Which is not usually the case.</p>
<p>Jamis++</p>
<p><strong>Update:</strong>  Ok, turning it into a gdb macro is dead easy.  Save this lot into ~/ruby.gdb</p>
<pre>
  # A quick hack to show the environment for a Ruby process.

  define printenv
    set $index = 0
    while environ[$index]
      x/1s environ[$index]
      set $index = $index + 1
    end
  end

  document printenv
    Display the environment for the current process.
  end

  define rb_where
    set $ary = (int)backtrace(-1)
    set $count = *($ary+8)
    set $index = 0
    while $index &lt; $count
      x/1s *((int)rb_ary_entry($ary, $index)+12)
      set $index = $index + 1
    end
  end

  document rb_where
    Show the ruby stacktrace.
  end
</pre>
<p>To use it do <code>source ~/ruby.gdb</code> from the gdb session, and then you get two new commands: <code>printenv</code> and <code>rb_where</code>.</p>
<p>Oh yes, I <strong>do</strong> know how super-trivial all this would be if only I had <a href="http://www.sun.com/bigadmin/content/dtrace/">DTrace</a>.  Roll on <a href="http://www.apple.com/macosx/leopard/xcode.html">Leopard</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/09/22/gdb-ruby-pid/feed/</wfw:commentRss>
		</item>
		<item>
		<title>YAPC Back, see</title>
		<link>http://happygiraffe.net/blog/2006/09/02/yapc-back-see/</link>
		<comments>http://happygiraffe.net/blog/2006/09/02/yapc-back-see/#comments</comments>
		<pubDate>Sat, 02 Sep 2006 22:43:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[yapc]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article1016</guid>
		<description><![CDATA[After spending the bank holiday in Wales, I trotted off to Brum for YAPC::Europe 2006.  It&#8217;s my first YAPC and a heck of an experience.  3 days of being immersed in Perl and Perl people.  I took in a heck of a lot&#8230;

I have to learn how to get Catalyst working.  [...]]]></description>
			<content:encoded><![CDATA[<p>After spending the bank holiday in Wales, I trotted off to Brum for <a href="http://birmingham2006.com/"><span class="caps">YAPC</span>::Europe 2006</a>.  It&#8217;s my first <span class="caps">YAPC</span> and a heck of an experience.  3 days of being immersed in Perl and Perl people.  I took in a heck of a lot&#8230;</p>
<ul>
<li>I have to learn how to get <a href="http://catalyst.perl.org/">Catalyst</a> working.  Actually, I did a bit of that on the train on the way back thanks to the <span class="caps">CPAN</span> mirror that they handed out in the goodie bag and the power sockets on Virgin trains.  I wish I had understood more of Matt Trout&#8217;s presentation, but it whizzed past at hypersonic speed.</li>
<li>Jos Boumans is a sick puppy.  He did the funniest presentation of the conference, &#8220;Barely Legal <span class="caps">XXX</span> Perl&#8221;.  An exploration of how to twist Perl into successfully compiling and running <a href="http://search.cpan.org/~adamk/Acme-BadExample-1.00/lib/Acme/BadExample.pm">Acme::BadExample</a>.  As amusing as it was, it also provides a keen insight into techniques that might come in useful if sufficiently encapsulated&#8230;
<ul>
<li>During this talk, <a href="http://simon-cozens.org/">Simon Cozens</a> found a bug <a href="http://search.cpan.org/~nwclark/perl-5.8.8/lib/less.pm">less.pm</a>.  Yow!</li>
</ul>
</li>
<li><a href="http://search.cpan.org/dist/Moose/">Moose</a> needs to be investigated further.  It seems like a good bid at providing a sane OO environment for Perl.  It looks like a good step towards Perl 6.  It&#8217;s still using a blessed hash, but that&#8217;s probably a good thing on the whole; it means Data::Dumper still works.</li>
<li>I attended two talks on <a href="http://poe.perl.org/"><span class="caps">POE</span></a>.  Firstly, Merijn Broeren gave an overview of all the weird terminology associated with it.  At this point, I wasn&#8217;t <em>completely</em> put off.  But Jan-Pieter Cornet&#8217;s &#8220;Fun with <span class="caps">POE</span>&#8221; on the second day really helped bring things into perspective.  We spent an hour and a half creating an <span class="caps">IRC</span> bot that did various things up to and including acting as a <span class="caps">DNS</span> <em>server!</em>  It&#8217;s definitely something I&#8217;m going to try and use as soon as I get a chance.</li>
<li>I missed <a href="http://bulknews.typepad.com/blog/">Tatsuhiko Miyagawa&#8217;s</a> <a href="http://plagger.org">Plagger</a> talk, but it was a good one by all accounts (certainly the <a href="http://plagger.org/trac/attachment/wiki/WikiStart/Plagger-OSCON2006.pdf?format=raw">slides</a> I read afterwards piqued my interest).  Unfortunately, I don&#8217;t have a use for an utterly pluggable <span class="caps">RSS</span>/Atom aggregator.  Yet.  Good to know it&#8217;s there though.  It does pull in half of <span class="caps">CPAN</span>, however.  I seem to recall somebody saying afterwards that it completely overheated their laptop and used up all the battery installing it.</li>
<li>The Lightning Talks were mostly pretty good.
<ul>
<li><a href="http://bulknews.typepad.com/blog/">Tatsuhiko Miyagawa</a> demonstrating <a href="http://bulknews.typepad.com/blog/2006/06/control_google_.html">scrolling google maps</a> by tilting his thinkpad was brilliant.   I am in awe of being able to think that one up <strong>and</strong> make it work&#8230;</li>
<li>&#8220;undef isn&#8217;t&#8221; was hilarious and succeeded in its goal of making <code>undef</code> a lot less well defined.  Although it did remind me of Python, which allows you to assign a new value to <code>None</code> (at least it warns at you for doing this these days).</li>
<li><a href="http://www.jifty.org/">Jifty</a> rocks.  Must look at that too.  It seems more rails like than Catalyst, which is preferable for some of the things I&#8217;m looking at right now.</li>
<li><a href="http://search.cpan.org/dist/HTTP-Async/"><span class="caps">HTTP</span>::Async</a> by Edmund van der Burg is a neat module that appears to solve a common problem in a nice simple way.</li>
<li>Tim Bunce&#8217;s work on <span class="caps">DBI</span> for parrot looks fascinating.  I really appreciated his humility when he talked about reusing the <span class="caps">JDBC API</span> where possible&#8230;</li>
<li>I have a request to people: Please stop creating more <span class="caps">XML</span> Writers!  Aaron Crane did a talk about the 30+ Getopt modules on <span class="caps">CPAN</span>.  I feel that it&#8217;s getting that way about <span class="caps">XML</span> Writers&#8230; (disclaimer: I&#8217;ve written two and they both suck).</li>
</ul>
</li>
<li><a href="http://www.astray.com/">Acme</a> did a superb talk about searching in Perl.  He covered <a href="http://search.cpan.org/~creamyg/KinoSearch-0.13/">KinoSearch</a>, <a href="http://search.cpan.org/~mceglows/Search-ContextGraph-0.15/">Search::ContextGraph</a> and <a href="http://search.cpan.org/~mdehoon/Algorithm-Cluster-1.32/">Algorithm::Cluster</a>.  For me, this really built on <a href="http://jibsheet.com/">Kevin Falcone&#8217;s</a> talk summing up the options for searching in Perl.</li>
<li>If you haven&#8217;t used <a href="http://search.cpan.org/~timb/DBI-1.52/lib/DBI/Profile.pm">profiling</a> in <span class="caps">DBI</span> yet, learn how.  You can do a heck of a lot with it.  Oh, and if you&#8217;re doing bulk loading, check out <code>execute_for_fetch()</code>.</li>
<li>There were two non-Perl talks: <a href="http://martian.org/marty/">Marty Pauley</a> on lithp (a discussion of where lisp came from and why you should learn it) and Bernd Ullman on <a href="http://en.wikipedia.org/wiki/APL_programming_language"><span class="caps">APL</span></a>, which was hilarious (most people debug <span class="caps">APL</span> by throwing it away and writing it again).  Scarily, <span class="caps">APL</span> is still seeing active use in financial institutions&#8230;</li>
<li>Bernd also gave a great insight into the sheer pain of getting Perl running on an <span class="caps">IBM</span> mainframe.  It scared and delighted me in almost equal measure.</li>
<li>Smylers talk on recruiting Perl programmers was full of useful advice.  It really gave you some good ways to think about how to test your candidates.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/09/02/yapc-back-see/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Unicode Depresses Me</title>
		<link>http://happygiraffe.net/blog/2006/08/20/unicode-depresses-me/</link>
		<comments>http://happygiraffe.net/blog/2006/08/20/unicode-depresses-me/#comments</comments>
		<pubDate>Sun, 20 Aug 2006 16:14:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[perl]]></category>

		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article850</guid>
		<description><![CDATA[Perl is meant to have reasonable Unicode support.  So why do I still have to write this at the top of a test?

  use utf8;
  use Test::More 'no_plan';
  {
      my $Test = Test::Builder-&#62;new;
      binmode( $Test-&#62;output,       [...]]]></description>
			<content:encoded><![CDATA[<p>Perl is meant to have <em>reasonable</em> Unicode support.  So why do I still have to write this at the top of a test?</p>
<pre>
  use utf8;
  use Test::More 'no_plan';
  {
      my $Test = Test::Builder-&gt;new;
      binmode( $Test-&gt;output,         ":utf8" );
      binmode( $Test-&gt;failure_output, ":utf8" );
      binmode( $Test-&gt;todo_output,    ":utf8" );
  }
</pre>
<p>I would have thought that adding the <a href="http://perldoc.perl.org/perlrun.html#*-C-%5b_number%2flist_%5d*--C">-CS</a> flag to the #! line would have fixed this.  But that doesn&#8217;t do it.  Ah well, I&#8217;ve filed a wishlist bug: <a href="http://rt.cpan.org/Ticket/Display.html?id=21091">RT#21091</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/08/20/unicode-depresses-me/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Lexical Attributes</title>
		<link>http://happygiraffe.net/blog/2006/07/27/lexical-attributes/</link>
		<comments>http://happygiraffe.net/blog/2006/07/27/lexical-attributes/#comments</comments>
		<pubDate>Thu, 27 Jul 2006 10:05:00 +0000</pubDate>
		<dc:creator>dom</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">tag:happygiraffe.net:Article834</guid>
		<description><![CDATA[A week or two ago, I took an idea from Aristotle about &#8220;shortcut&#8221; functions and made it into a little module: Attribute-Shortcut.  Aristotle pointed out in the comments that the attributes should also work on coderefs as well as named subs.  i.e.

  sub basename :Shortcut { s!.*/!! for @_ };
  my [...]]]></description>
			<content:encoded><![CDATA[<p>A week or two ago, I took an <a href="http://use.perl.org/~Aristotle/journal/30226">idea</a> from Aristotle about &#8220;shortcut&#8221; functions and made it into a little module: <a href="http://happygiraffe.net/svn/public/Attribute-Shortcut/trunk/">Attribute-Shortcut</a>.  Aristotle pointed out in the comments that the attributes should also work on coderefs as well as named subs.  i.e.</p>
<pre>
  sub basename :Shortcut { s!.*/!! for @_ };
  my $basename = sub :Shortcut { s!.*/!! for @_ };
</pre>
<p>However, I can&#8217;t seem to find a way to make this work.  <a href="http://search.cpan.org/~abergman/Attribute-Handlers-0.78/lib/Attribute/Handlers.pm">Attribute::Handlers</a> passes you the string &#8220;ANON&#8221; instead of a glob reference.</p>
<p>Looking deeper at the documentation for <a href="http://perldoc.perl.org/attributes.html#DESCRIPTION">attributes</a>, it seems to imply that attributes on lexical variables aren&#8217;t really very well supported anyway.</p>
<p>I think I may have to conclude that this isn&#8217;t going to work for now&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://happygiraffe.net/blog/2006/07/27/lexical-attributes/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
