<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>jhthorsen's perl blog</title>
  <link href="http://jhthorsen.github.com/ironman.xml" rel="self" />
  <link href="http://jhthorsen.github.com/"/>
  <updated>2009-09-18T15:05:34-07:00</updated>
  <id>http://jhthorsen.github.com/</id>
  <author>
    <name>Jan Henning Thorsen</name>
    <email>jhthorsen@cpan.org</email>
  </author>
  
  <entry>
    <title>CatalystX::Controller::Sugar</title>
    <link href="http://jhthorsen.github.com/perl/2009/09/10/catalyst-controller-sugar.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2009-09-10T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2009/09/10/catalyst-controller-sugar</id>
    <content type="html">&lt;p&gt;I&amp;#8217;ve written a module I think is rather useful: &lt;a href='http://search.cpan.org/perldoc?CatalystX::Controller::Sugar'&gt;CatalystX::Controller::Sugar&lt;/a&gt;. This module (will hopefully) make chained actions be your default when writing a controller in &lt;a href='http://search.cpan.org/perldoc?Catalyst::Runtime'&gt;Catalyst&lt;/a&gt;. I remember when I first started looking at Catalyst - I didn&amp;#8217;t see the reason for doing chained actions, and I certainly didn&amp;#8217;t understand how they worked. I still think it&amp;#8217;s a pain to set it up, but hopefully it&amp;#8217;s a bit easier using the sugar module.&lt;/p&gt;

&lt;p&gt;In addition to sugar for chains, it exports some other functions, which I use most the time. This is something I think is a pain:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# 139 characters
sub foo :Chain(&amp;#39;/&amp;#39;) PathPart(&amp;#39;&amp;#39;) CaptureArgs(0) {
  my $self = shift;
  my $c = shift;
  $c-&amp;gt;stash-&amp;gt;{&amp;#39;answer_to_everything&amp;#39;} = 42;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#8230;which can be written this way, with sugar:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# 53 characters
chain sub {
    stash answer_to_everything =&amp;gt; 42;
};&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I hardly ever use &lt;code&gt;$self&lt;/code&gt;, but I wery often use &lt;code&gt;stash()&lt;/code&gt;, &lt;code&gt;session()&lt;/code&gt; and &lt;code&gt;forward()&lt;/code&gt; so that&amp;#8217;s why I&amp;#8217;ve chosen to export those functions (among some others). The module is also quite simple to use:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use CatalystX::Controller::Sugar;
# your controller code
1;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#8230;instead of:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use CatalystX::Controller;
use Moose;
BEGIN { extends &amp;#39;Catalyst::Controller&amp;#39; }
# your controller code
1;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Does my pod suck? Is the module not flexible enough? Let me know.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>rt.cpan.org - great fun!</title>
    <link href="http://jhthorsen.github.com/perl/2009/09/09/rt-tickets.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2009-09-09T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2009/09/09/rt-tickets</id>
    <content type="html">&lt;p&gt;I must say I enjoy getting rt-tickets. &amp;#8220;Why?&amp;#8221;, you might ask. Well, It&amp;#8217;s probably the only way I can actually know that someone use, or has tried to use a module &lt;a href='http://search.cpan.org/~jhthorsen'&gt;I&amp;#8217;ve written&lt;/a&gt;. The bad (if you can call it bad) thing about getting a ticket is that it&amp;#8217;s rather critical that it gets fixed. This part I&amp;#8217;m not so good at. But let&amp;#8217;s not forget that it&amp;#8217;s not only the original auther that can fix a bug&amp;#8230; Which reminds me that I should also file some bugs/requests/patches to various projects I&amp;#8217;ve forked off &lt;a href='http://github.com'&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So much to do, and so little time :-)&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Line noise: parentheses</title>
    <link href="http://jhthorsen.github.com/perl/2009/06/01/line-noise-parentheses.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2009-06-01T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2009/06/01/line-noise-parentheses</id>
    <content type="html">&lt;p&gt;I&amp;#8217;ve been discussing how bad perl code looks and I&amp;#8217;m a bit surprised: I consider () more noisy than $, %, @ and friends, while the people I discuss this with, really likes parentheses. Consider this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;push(@text, sprintf(&amp;#39;I got %i foos&amp;#39;, int(shift(@{ $obj-&amp;gt;get_foo() }))));&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Versus:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;push @text, sprintf &amp;#39;I got %i foos&amp;#39;, int shift @{ $obj-&amp;gt;get_foo };&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I don&amp;#8217;t understand how the first one is less noisy than the second (!). I also don&amp;#8217;t understand how you can maintain or read the first one.&lt;/p&gt;

&lt;p&gt;Disclaimer: Yes, I know the example code doesn&amp;#8217;t make any sense.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Wow, Moose is cool!</title>
    <link href="http://jhthorsen.github.com/perl/2009/05/30/moose-is-cool.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2009-05-30T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2009/05/30/moose-is-cool</id>
    <content type="html">&lt;p&gt;I was introducing &lt;a href='http://search.cpan.org/dist/Moose'&gt;Moose&lt;/a&gt; (and perl oo) to a java guy the other day, and he replied: &amp;#8220;No, shit. Is that possible?&amp;#8221;, &amp;#8220;Now I understand the fuzz about multiple inheritance&amp;#8221; and &amp;#8220;Wow, Moose is cool!&amp;#8221;.&lt;/p&gt;

&lt;p&gt;I must confess: It brings comfort to my heart to hear a &lt;a href='http://en.wikipedia.org/wiki/Java_%28programming_language%29'&gt;Java&lt;/a&gt; guy talk down on his own language, but it&amp;#8217;s even sweeter to hear something nice about perl.&lt;/p&gt;

&lt;p&gt;But back to the topic: What was so cool about Moose? The short answer is &lt;a href='http://search.cpan.org/dist/Moose/lib/Moose/Manual/Roles.pod'&gt;Moose::Role&lt;/a&gt;. I had a hard time understanding roles, and the usage for them, but after getting the short answer &amp;#8220;You use roles to build your classes, and your classes to build objects&amp;#8221; - it suddenly got a lot clearer to me.&lt;/p&gt;

&lt;p&gt;Roles to build classes, ey? Yes, instead of putting functionality in different packages, and inheriting from them, you write roles and &lt;em&gt;consume&lt;/em&gt; their functionality in a class, which imho gives me a lot cleaner interface.&lt;/p&gt;

&lt;p&gt;I try to look at Roles like something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;package Foo;
do MyOtherFile.pm;
1;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But of course there&amp;#8217;s a lot more &lt;a href='http://search.cpan.org/dist/Moose/lib/Moose/Manual/Unsweetened.pod'&gt;sugar&lt;/a&gt; to it in &amp;#8220;Mooseland&amp;#8221; :-)&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Which name to pick?</title>
    <link href="http://jhthorsen.github.com/perl/2009/05/12/dhcpd-module-name.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2009-05-12T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2009/05/12/dhcpd-module-name</id>
    <content type="html">&lt;p&gt;I&amp;#8217;m writing a new &lt;a href='http://github.com/jhthorsen/net-isc-dhcpd'&gt;module&lt;/a&gt;, which is currently named &amp;#8220;Net::DHCPd&amp;#8221;. It&amp;#8217;s not a good name imo, since Net::DHCPd sounds more like a module that actually &lt;em&gt;is&lt;/em&gt; a dhcp server, which mine is not.&lt;/p&gt;

&lt;p&gt;This is what it can, or is supposed to support in the future:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interact with ISC DHCPd&lt;/li&gt;

&lt;li&gt;Start/stop/restart the daemon&lt;/li&gt;

&lt;li&gt;Parse and build config&lt;/li&gt;

&lt;li&gt;Check config file for error&lt;/li&gt;

&lt;li&gt;Parse leases file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So what should it be called? I&amp;#8217;m thinking about naming it ISC::DHCPd, since it&amp;#8217;s primary target is to interact with that spesific server. But can I call it the same as what &lt;a href='https://www.isc.org/software/dhcp'&gt;the actual server&lt;/a&gt; is called?&lt;/p&gt;

&lt;p&gt;Let me know if you have any idea.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>More perl modules</title>
    <link href="http://jhthorsen.github.com/perl/2008/05/06/more-perl-modules.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2008-05-06T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2008/05/06/more-perl-modules</id>
    <content type="html">&lt;p&gt;I&amp;#8217;m working on some more perl-modules now: &lt;a href='http://search.cpan.org/dist/YAML-Object'&gt;YAML::Object&lt;/a&gt; and &lt;a href='http://search.cpan.org/dist/POE-Component-TFTPd'&gt;POE::Component::TFTPd&lt;/a&gt;. I&amp;#8217;ve also fixed some issues with SNMP::Effective, and written a &lt;a href='http://github.com/jhthorsen/snmp-effective/tree/net-snmp'&gt;new implementation&lt;/a&gt;, that uses Net::SNMP instead of SNMP.&lt;/p&gt;

&lt;p&gt;The YAML-module is a result of bad typing: I&amp;#8217;m quite sick of doing &amp;#36;config-&amp;gt;{typoo}{key}. YAML::Object enables you to use method notation, so the above would become $config-&amp;gt;typoo-&amp;gt;key, and calling key() on an undef value will barf with a nice error message.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;m pretty exited about the POE::Component, since I&amp;#8217;ve never written anything quite like it before. Check out &lt;a href='http://search.cpan.org/dist/POE'&gt;POE&lt;/a&gt; If you haven&amp;#8217;t already done so, it&amp;#8217;s really cool :)&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>YAPC::Europe::2007 Vienna</title>
    <link href="http://jhthorsen.github.com/perl/2007/08/30/yapc-europe-2007-vienna.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2007-08-30T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2007/08/30/yapc-europe-2007-vienna</id>
    <content type="html">&lt;p&gt;&lt;a href='http://vienna.yapceurope.org/ye2007'&gt;YAPC::Europe::2007&lt;/a&gt; was a blast! I can&amp;#8217;t really put my finger on what was the best, because it was all good. I really recommend every Perl-programmer out there to come to next years YAPC in Denmark/Copenhagen.I had a talk this year as well (Operator overloading, one of the magicks of Perl), but I wasn&amp;#8217;t any happy about it. Even so, I got some positive feedback, which I don&amp;#8217;t really understand. I will try again next year, if they accept me. I might have to trick them into accepting me, since it&amp;#8217;s a bit off topic, but I&amp;#8217;ll wait and see&amp;#8230;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>YAPC::Europe::2006 Birmingham</title>
    <link href="http://jhthorsen.github.com/perl/2006/09/04/yapc-europe-2006.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2006-09-04T00:00:00-07:00</updated>
    <id>http://jhthorsen.github.com/perl/2006/09/04/yapc-europe-2006</id>
    <content type="html">&lt;p&gt;Hello peeps. It&amp;#8217;s been a while now, but I finally got some spare time to communicate with the world again&amp;#8230;&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been to the &lt;a href='http://birmingham2006.com'&gt;YAPC::Europe&lt;/a&gt; this week, and I must say it was quite fun &amp;#8211; or at least the time I actually spent in Birmingham. &lt;a href='http://home.flodhest.net/files/perl/yapc::2006/diary'&gt;Read more&lt;/a&gt; in my diary.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>SNMP::Effective</title>
    <link href="http://jhthorsen.github.com/perl/2006/02/19/snmp-effective.html" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#category" />
    <category term="perl" scheme="http://www.sixapart.com/ns/types#tag" />
    <updated>2006-02-19T00:00:00-08:00</updated>
    <id>http://jhthorsen.github.com/perl/2006/02/19/snmp-effective</id>
    <content type="html">&lt;p&gt;I&amp;#8217;m done writing the code for SNMP::Effective now. It has show to be quite promising after some tests: 4000 hosts in 50 seconds is quite better than what I had with a &lt;acronym title='1.8 hosts pr second'&gt;previous
module&lt;/acronym&gt;. I&amp;#8217;m hoping to release SNMP::Effective on &lt;a href='http://cpan.org'&gt;CPAN&lt;/a&gt;, later this year. But first I need to complete &lt;a href='http://www.google.com/search?q=eadmin%20eidolon%20as'&gt;eAdmin 2.0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the meanwhile, you could try &lt;a href='http://search.cpan.org/~tpg/SNMP-Multi'&gt;SNMP::Multi&lt;/a&gt;, which gave me the idea to write my own.&lt;/p&gt;</content>
  </entry>
  
</feed>
