<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>divisionbyzero &#187; perl</title>
	<atom:link href="http://divisionbyzero.net/blog/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://divisionbyzero.net/blog</link>
	<description>question . authority</description>
	<lastBuildDate>Tue, 06 Jul 2010 16:43:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Baltimore Perl Mongers, July 15th 6:30 PM</title>
		<link>http://divisionbyzero.net/blog/2010/07/06/baltimore-perl-mongers-july-15th-630-pm/</link>
		<comments>http://divisionbyzero.net/blog/2010/07/06/baltimore-perl-mongers-july-15th-630-pm/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 16:43:27 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[beer]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=183</guid>
		<description><![CDATA[Mike Barry is doing an excellent job running the Baltimore Perl Mongers, and attendance has been solid at 5-6 people or so.  It would be nice to have a few new faces, but the current crowd is awesome. Where: ETC, Canton When: Thursday, July 15th 6:30 PM What: Perl + Beer Alan will be giving [...]]]></description>
			<content:encoded><![CDATA[<p>Mike Barry is doing an excellent job running the Baltimore Perl Mongers, and attendance has been solid at 5-6 people or so.  It would be nice to have a few new faces, but the current crowd is awesome.</p>
<p>Where: <a title="Directions to the ETC" href="http://maps.google.com/maps?daddr=2400+boston+street+baltimore+md" target="_blank">ETC, Canton</a></p>
<p>When: <strong>Thursday, July 15th 6:30 PM</strong></p>
<p>What: <strong>Perl + Beer</strong></p>
<p>Alan will be giving a talk on some of the P2P work he&#8217;s been doing.  Mike might also put together a short talk on what he learned at <a title="YAPC::NA 2010" href="http://yapc2010.com/yn2010/" target="_blank">YAPC::NA 2010</a>.  Baltimore.PM is going to invade <a title="CPOSC " href="http://www.cposc.org/" target="_blank">CPOSC</a> this year, manning a table for <a title="The Perl Foundation" href="http://www.perlfoundation.org/" target="_blank">The Perl Foundation</a>.  We&#8217;ll present this idea to the group, and probably use the next meeting to sign people up for the table.</p>
<p>Spread the word!</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2010/07/06/baltimore-perl-mongers-july-15th-630-pm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Baltimore Perl Mongers Meeting TONITE!</title>
		<link>http://divisionbyzero.net/blog/2010/06/17/baltimore-perl-mongers-meeting-tonite/</link>
		<comments>http://divisionbyzero.net/blog/2010/06/17/baltimore-perl-mongers-meeting-tonite/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 13:58:10 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[baltimorepm]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=174</guid>
		<description><![CDATA[Details as follows: When: Thursday, June 17th 6:30 PM Where: Emering Technology Center in Canton 2400 Boston Street Baltimore, MD 21224 Format is Lightning Talks.  I&#8217;ll be doing a talk about Perl Install and Management through a System Configuration Engine like Puppet and cfEngine. UPDATE: PerlManagement Slides uploaded.]]></description>
			<content:encoded><![CDATA[<p>Details as follows:</p>
<p><strong>When:</strong> Thursday, June 17th 6:30 PM</p>
<p><strong>Where: </strong></p>
<p>Emering  Technology Center in Canton<br />
2400 Boston Street<br />
Baltimore, MD 21224</p>
<p><strong>Format is Lightning Talks</strong>.  I&#8217;ll be doing a talk about Perl Install and Management through a System Configuration Engine like Puppet and cfEngine.</p>
<p>UPDATE: <a href="http://divisionbyzero.net/blog/wp-content/uploads/2010/06/PerlManagement.pdf">PerlManagement</a> Slides uploaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2010/06/17/baltimore-perl-mongers-meeting-tonite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Baltimore Perl Mongers Relaunch</title>
		<link>http://divisionbyzero.net/blog/2010/04/09/baltimore-perl-mongers-relaunch/</link>
		<comments>http://divisionbyzero.net/blog/2010/04/09/baltimore-perl-mongers-relaunch/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 18:52:38 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[baltimore]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=168</guid>
		<description><![CDATA[After a long slumber, the Baltimore Perl Mongers Group is being revived with a new found vigor.  Details are as follows: When: Thursday, April 15th 6:30 PM Where: Emering Technology Center in Canton 2400 Boston Street Baltimore, MD 21224 Speaker: Mike Barry  of Refworks / COS Talk: &#8220;What is Modern Perl?&#8221; Please try to make [...]]]></description>
			<content:encoded><![CDATA[<p>After a long slumber, the Baltimore Perl Mongers Group is being revived with a new found vigor.  Details are as follows:</p>
<p><strong>When:</strong> Thursday, April 15th 6:30 PM</p>
<p><strong>Where: </strong></p>
<p style="padding-left: 30px;"><strong></strong>Emering Technology Center in Canton<br />
2400 Boston Street<br />
Baltimore, MD 21224</p>
<p><strong>Speaker: </strong>Mike Barry  of Refworks / COS</p>
<p><strong>Talk: </strong>&#8220;What is Modern Perl?&#8221;</p>
<p>Please try to make this meeting as we&#8217;ll be discussing moving the group to meetup.com or another group scheduling app and new directions for getting Baltimore Area Perl Mongers together in a room.  Drinks at a local watering hole are probable.</p>
<p>If you can&#8217;t attend, help get the word out.  This has been a long time coming!</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2010/04/09/baltimore-perl-mongers-relaunch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Perl on Twitter</title>
		<link>http://divisionbyzero.net/blog/2009/09/17/perl-on-twitter/</link>
		<comments>http://divisionbyzero.net/blog/2009/09/17/perl-on-twitter/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 16:20:13 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=158</guid>
		<description><![CDATA[As a result of YAPC::NA 10, I was inspired to get more involved in Social Media. The idea is to promote and learn about new technologies through Social Media while injecting a sane, intelligent under current of Modern Perl. I finally started to use my Twitter account. I&#8217;ve noticed the majority of tweets regarding Perl [...]]]></description>
			<content:encoded><![CDATA[<p>As a result of <a href="http://yapc10.org/yn2009/">YAPC::NA 10</a>, I was inspired to <a href="http://ironman.enlightenedperl.org/">get more involved in Social Media</a>.  The idea is to promote and learn about new technologies through Social Media while injecting a sane, intelligent under current of Modern Perl.</p>
<p>I finally started to use <a href="http://twitter.com/reyjrar">my Twitter account</a>. I&#8217;ve noticed the majority of tweets regarding Perl refer to it as torturous or antiquated or both.  These tweets are not coming from the Perl echo-chamber of <a href="http://www.perlmonks.org/">Perl Monks</a>, <a href="http://www.pm.org/">Perl Mongers</a>, and <a href="http://www.yapc.org/">Perl Conference</a> attendees, but from programmers exposed to Perl against their will.  This leaves a bad taste in their mouth, and when they hear &#8220;Perl,&#8221; their frame of reference is sadly the Matt&#8217;s Scripts Era of Perl Development.</p>
<p>I&#8217;m using <a href="http://tweetdeck.com/beta/">TweetDeck</a>, and I&#8217;ve created a search column for &#8220;perl.&#8221;  It gets a decent amount of traffic everyday.  I don&#8217;t have the time to respond to or even read every tweet about Perl, but I skim them maybe 4 or 5 times a day to find people with Perl problems or Perl frustration and point them in a better direction.  If you&#8217;re comfortable providing this type of assistance, I&#8217;d recommend TweetDeck with the &#8220;perl&#8221; Search Column as an interesting way to proselytize for Perl.  It does mean you&#8217;ll be subjected to the occasional teen ranting about &#8220;Perl Jam,&#8221; and of course you&#8217;ll likely writhe in agony at the number of times you see Perl referred to as &#8220;PERL.&#8221;  But if enough of the echo chamber is inundating the Twitterverse with intelligent, modern Perl advice, we might gain even more traction in the Social Media arena.</p>
<p>If you do tweet about Perl, follow <a href="http://hashtags.org/">HashTags</a> and tag your tweet with &#8220;<a href="http://hashtags.org/tag/perl/messages">#perl</a>&#8220;.</p>
<p>Just a thought, as I haven&#8217;t been able to hack in Perl in a few weeks due to other more pressing issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2009/09/17/perl-on-twitter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Vacation and PHP</title>
		<link>http://divisionbyzero.net/blog/2009/07/13/vacation-and-php/</link>
		<comments>http://divisionbyzero.net/blog/2009/07/13/vacation-and-php/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 02:53:40 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Rant]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl5]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=153</guid>
		<description><![CDATA[I took a much needed vacation the latter part of last week. Prior to that, I was helping a few coworkers with getting PHP Web Applications developed on Fedora Core 5 to run on CentOS 5 with upgraded PHP, Apache, and libraries. Every time I work with PHP, it gives me serious perspective as to [...]]]></description>
			<content:encoded><![CDATA[<p>I took a much needed vacation the latter part of last week.  Prior to that, I was helping a few coworkers with getting PHP Web Applications developed on Fedora Core 5 to run on CentOS 5 with upgraded PHP, Apache, and libraries.  Every time I work with PHP, it gives me serious perspective as to why the <a href="http://www.modernperlbooks.com" alt="Modern Perl">Modern Perl</a> / <a href="http://www.enlightenedperl.org">Enlightened Perl</a> / <a href="http://search.cpan.org/~mschwern/perl5i-20090424/lib/perl5i.pm">perl5i</a> Projects are incredibly important.  The Matt&#8217;s Scripts Perl era needs to die.  This stagnant snapshot has poisoned Perl&#8217;s reputation for too long.</p>
<p>The main difference between Perl and PHP, is writing maintainable, intelligent Perl is only slightly more work <em>at first</em> than writing horrible Matt&#8217;s Scripts style Perl.  With PHP, writing decent PHP is possible, but it&#8217;s incredibly difficult.  The majority of the PHP I&#8217;ve come across is code written by a web developer with no programming experience and the language design and direction accommodate that demographic.  PHP&#8217;s language design gets in the way of writing sane, maintainable code.  It&#8217;s not impossible, but you have to really, really want it.</p>
<p>When you write good Perl, the programming experience becomes easier, and more fun.</p>
<p>I&#8217;m trying to get back to my programming projects, and thus back to writing more on Perl.  For now, understand that if you think Perl and PHP are the same beast, you&#8217;re wrong.  I&#8217;ve been paid to develop both for periods of years.  Perl is much more eloquent, evolutionary, and intelligent.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2009/07/13/vacation-and-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using POE to hook syslog-ng</title>
		<link>http://divisionbyzero.net/blog/2009/07/02/using-poe-to-hook-syslog-ng/</link>
		<comments>http://divisionbyzero.net/blog/2009/07/02/using-poe-to-hook-syslog-ng/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 23:21:13 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl5]]></category>
		<category><![CDATA[poe]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[syslog]]></category>
		<category><![CDATA[syslog-ng]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=121</guid>
		<description><![CDATA[A massively code heavy post on integrating syslog into in house applications using syslog-ng and Perl's amazing POE Event Framework to do really crazy things!]]></description>
			<content:encoded><![CDATA[<p>Being able to do analysis, sorting, or database storage of syslog messages is incredibly useful.  There are tons of solutions on the market to do just that.  If you&#8217;re working on a system developed in house that you&#8217;d like to incorporate syslog messages into, then it may be easier to hook directly into the syslog stream than to introduce another piece of software into the environment which needs to be glued.</p>
<p>Syslog-ng facilitates easy integration with Perl binaries as the Perl program is spawned once during the daemon start up and a handle to that program&#8217;s STDIN is maintained for dispatching of messages.  Using POE, we can turn this into an event driven model, making additional complexity simple.</p>
<p>In this example, we&#8217;ll create a POE Master session that receives all of the syslog-ng input from STDIN.  Using off the shelf components, we&#8217;ll run a TCP Server on port 9514 that will allow clients to connect and subscribe to feeds based on the &#8220;program&#8221; name of the message being dispatched.<br />
<span id="more-121"></span><br />
Anytime I&#8217;m using Regular Expressions over and over, I like to &#8220;precook&#8221; them.  This compiles the regular expression, and lets the engine skip that step each time they&#8217;re used.  Doing so is simply a matter of declaring the regex with the <code>qr//</code> operator:</p>
<pre class="brush: perl;">
my %cooked = (
	program =&gt; qr/\s+\d+:\d+:\d+\s+\S+\s+([^:\s]+)(:|\s)/,
);
</pre>
<h2>Initialization</h2>
<p>Next we&#8217;ll create the administrative session in charge of dispatching the messages to the proper channels:</p>
<pre class="brush: perl;">
# Dispatcher Master Session
POE::Session-&gt;create(
	inline_states =&gt; {
		_start					=&gt; \&amp;dispatcher_start,
		_stop					=&gt; sub { print &quot;SESSION &quot;, $_[SESSION]-&gt;ID, &quot; stopped.\n&quot;; },
		register_client			=&gt; \&amp;register_client,
		subscribe_client		=&gt; \&amp;subscribe_client,
		hangup_client			=&gt; \&amp;hangup_client,

		dispatch_message		=&gt; \&amp;dispatch_message,
	},
);
</pre>
<p>We&#8217;ll define those subroutines shortly, but we need to setup the rest of our sessions.  Next, we&#8217;ll need a TCP Server to handle the client connections, we can get that using <code>POE::Component::Server::TCP</code>:</p>
<pre class="brush: perl;">
# TCP Session Master
POE::Component::Server::TCP-&gt;new(
		Alias		=&gt; 'server',
		Address		=&gt; '127.0.0.1',
		Port		=&gt; 9514,

		ClientConnected		=&gt; \&amp;client_connect,
		ClientInput			=&gt; \&amp;client_input,

		ClientDisconnected	=&gt; \&amp;client_term,
		ClientError			=&gt; \&amp;client_term,

		InlineStates		=&gt; {
			client_print		=&gt; \&amp;client_print,
		},
);
</pre>
<p>The final session will handle the Input on STDIN from syslog-ng:</p>
<pre class="brush: perl;">
# Syslog-ng Stream Master
POE::Session-&gt;create(
		inline_states =&gt; {
			_start		=&gt; \&amp;stream_start,
			_stop		=&gt; sub { print &quot;SESSION &quot;, $_[SESSION]-&gt;ID, &quot; stopped.\n&quot;; },
			stream_line		=&gt; \&amp;stream_line,
		},
);
</pre>
<p>Now we have to define the subroutines that we&#8217;ll be dispatching events to.  The heavy lifting is done by POE, and we&#8217;re left to handle simple things.</p>
<h1>Session Routines: <code>dispatcher</code></h1>
<p>This session is going to managing which clients receive which messages.  The actual input is handled by the <code>stream</code> session, and the sending of the messages to the client by the <code>server</code> session.  As we have a raw <code>POE::Session</code>, our first subroutine <code>dispatcher_start</code> is just going to do some basic preparation:</p>
<pre class="brush: perl;">
sub dispatcher_start {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel-&gt;alias_set( 'dispatcher' );  # allow named dispatch to this session.

	$heap-&gt;{subscribers} = {};
        $heap-&gt;{clients} = {};

}
</pre>
<p>Next event to be handled is the <i>register_client</i> event which is fired anytime a connection is established to the <code>server</code> session.  All the dispatcher does is register it&#8217;s session_id into an internal heap.  Nothing happens with it, but if we needed to send a message to all clients, we could loop over this hash and broadcast message.</p>
<pre class="brush: perl;">
sub register_client {
    # ARG0 =&gt; TCP Client Session ID
    my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

    $heap-&gt;{clients}{$sid} = 1;
}
</pre>
<p>Clients can subscribe to a program name, which they do by entering &#8220;<code>sub dhcpd, dnsmasq</code>&#8221; into the TCP Server.  It&#8217;s not fancy, but man is it convenient for debugging and development purposes.  The <code>server</code> session determines that the subscription is occurring and passes it&#8217;s argument string to the <code>dispatcher</code> session via the <i>subscribe_client</i> event.  This subroutine is called:</p>
<pre class="brush: perl;">
sub subscribe_client {
    # ARG0 =&gt; SID of Client
    # ARG1 =&gt; Argument String of the subscribe
	my ($kernel,$heap,$sid,$argstr) = @_[KERNEL,HEAP,ARG0,ARG1];

    # Split the input at commas or spaces into words:
	my @progs = map { lc } split /[\s,]+/, $argstr;
    # Add the SID to the list of Subscribed Clients for that program
	foreach my $prog (@progs) {
		$heap-&gt;{subscribers}{$prog}{$sid} = 1;
	}

    # Inform the client they've subscribed via client_print
	$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Subscribed to : ' . join(', ', @progs ) );
}
</pre>
<p>If a client disconnects, we remove it from the message dispatching hash:</p>
<pre class="brush: perl;">
sub hangup_client {
    # ARG0 =&gt; SID of Client Disconnecting
	my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

	delete $heap-&gt;{clients}{$sid};

	foreach my $p ( keys %{ $heap-&gt;{subscribers} } ) {
		delete $heap-&gt;{subscribers}{$p}{$sid}
			if exists $heap-&gt;{subscribers}{$p}{$sid};
	}
}
</pre>
<p>Now comes the most important event the dispatcher handles, <i>dispatch_message</i>.  In this event, we have a message from syslog-ng that needs to go to interested parties.  This event determines the &#8220;program&#8221; and it&#8217;s subscribers and sends that message along appropriately:</p>
<pre class="brush: perl; highlight: [14];">
sub dispatch_message {
    # ARG0 =&gt; The raw message from syslog-ng
	my ($kernel,$heap,$msg) = @_[KERNEL,HEAP,ARG0];

    # Determine the program name
	if( my ($program) = map { lc } ($msg =~ /$cooked{program}/) ) {
		# remove the sub process and PID from the program
		$program =~ s/\(.*//g;
		$program =~ s/\[.*//g;

        # If we have subscribers, send them the message.
		if( exists $heap-&gt;{subscribers}{$program} ) {
			foreach my $sid (keys %{ $heap-&gt;{subscribers}{$program} }) {
				$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; $msg );
			}
		}
}
</pre>
<p>You'll notice on line 14 above, the <code>post( $sid => client_print => $msg )</code> sends the event to the appropriate client and calls the <i>client_print</i> event on itself.  This is all the dispatcher needs to do.  The rest is handled by other other sessions.</p>
<h1>Session Routines: <code>server</code></h1>
<p>This session accepts new tcp clients and handles writing to the sockets.  We'll take a look at a few subroutines here.  Fist we'll look at the <i>ClientConnect</i> event.</p>
<pre class="brush: perl;">
sub client_connect {
    # SESSION is the client's session object
	my ($kernel,$heap,$ses) = @_[KERNEL,HEAP,SESSION];

	my $SID = $ses-&gt;ID;

    # Register the Client with the Dispatcher
	$kernel-&gt;post( 'dispatcher' =&gt; 'register_client' =&gt; $SID );

    # Store the current entry for 'client' in the heap so we can communicate later
	$heap-&gt;{clients}{ $SID } = $heap-&gt;{client};

	# Say hello to the client.
	$heap-&gt;{client}-&gt;put( &quot;Hello Client: $SID&quot; );
}
</pre>
<p>We also need a <i>disconnect</i> event:</p>
<pre class="brush: perl;">
sub client_term {
	my ($kernel,$heap,$ses) = @_[KERNEL,HEAP,SESSION];
	my $sid = $ses-&gt;ID;

    # Delete the Client's Dispatch Table
	delete $heap-&gt;{dispatch}{$sid};
    # Tell the dispatcher session we're through
	$kernel-&gt;post( 'dispatcher' =&gt; 'hangup_client' =&gt;  $sid );
}
</pre>
<p>Next we&#8217;ll handle sending message to the client, which is incredibly easy:</p>
<pre class="brush: perl;">
sub client_print {
    # ARG0 =&gt; Message to Send to the Client
	my ($kernel,$heap,$ses,$mesg) = @_[KERNEL,HEAP,SESSION,ARG0];

	$heap-&gt;{clients}{$ses-&gt;ID}-&gt;put($mesg);
}
</pre>
<p>Now we a routine to handle the <i>ClientInput</i> event.  This event will take commands from the clients and do something with them.  We&#8217;ll use an internal dispatch table in the form of a hash to handle translating commands.  This will allow us to expand our API if we need to.</p>
<pre class="brush: perl; highlight: [12,13,14,15,34,36];">
sub client_input {
    # SESSION is the Client Session Object with input
    # ARG0 =&gt; Input waiting from that client
	my ($kernel,$heap,$ses,$msg) = @_[KERNEL,HEAP,SESSION,ARG0];
	my $sid = $ses-&gt;ID;

    # Build a Dispatch Table if one does not exists in the heap for this entry.
	if( !exists $heap-&gt;{dispatch}{$sid} ) {
		$heap-&gt;{dispatch}{$sid} = {

			subscribe		=&gt; {
				re			=&gt; qr/^sub(?:scribe)? (.*)/,
				callback	=&gt; sub {
					$kernel-&gt;post( 'dispatcher' =&gt; 'subscribe_client' =&gt; $sid, shift );
				},
			},
            # FUTURE API for Clients receiving every message!
			#fullfeed		=&gt; {
			#	re			=&gt; qr/^(fullfeed)/,
			#	callback	=&gt; sub {
			#		$kernel-&gt;post( 'dispatcher' =&gt; 'fullfeed_client' =&gt; $sid );
			#	},
			#},
		};
	}

	#
	# Check for messages:
	my $handled = 0;
    # Get Our Dispatch Table
	my $dispatch = $heap-&gt;{dispatch}{$sid};
    # Look up and take action according to our dispatch table
	foreach my $evt ( keys %{ $dispatch } ) {
		if( my($args) = ($msg =~ /$dispatch-&gt;{$evt}{re}/)) {
			$handled = 1;
			$dispatch-&gt;{$evt}{callback}-&gt;($args);
			last;
		}
	}

    # Inform the client that their command was not understood.
	if( !$handled ) {
		$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'UNKNOWN COMMAND, Ignored.' );
	}
}
</pre>
<p>That&#8217;s the most complicated routine in the program, but it does allow us to morph the dispatch tables for individual clients.  Lines 12-15 build a dispatch table entry with the regular expression to match the command, followed by a callback subroutine reference which handles the command.  Lines 34 and 36 are where these rules are applied to the input from the client.</p>
<h1>Session Routines: <code>stream</code></h1>
<p>The last session is very simple.  This session maintains the connection to STDIN from syslog-ng and dispatches those lines as events to the <code>dispatcher</code> session.  There is a startup routine:</p>
<pre class="brush: perl;">
sub stream_start {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel-&gt;alias_set( 'stream' );

	#
	# Initialize the connection to STDIN as a POE::Wheel
	my $stdin = IO::Handle-&gt;new_from_fd( \*STDIN, 'r' );
	my $stderr = IO::Handle-&gt;new_from_fd( \*STDERR, 'w' );

	$heap-&gt;{stream} = POE::Wheel::ReadWrite-&gt;new(
		InputHandle		=&gt; $stdin,
		OutputHandle	=&gt; $stderr,
		InputEvent		=&gt; 'stream_line',
	);
}
</pre>
<p>And the <i>stream_line</i> event which sends the incoming syslog messages to the <code>dispatcher</code> session for processing:</p>
<pre class="brush: perl;">
#--------------------------------------------------------------------------#
sub stream_line {
    # ARG0 =&gt; Line from STDIN, New line delimited.
	my ($kernel,$msg) = @_[KERNEL,ARG0];

	return unless length $msg;

	$kernel-&gt;post( 'dispatcher' =&gt; 'dispatch_message' =&gt; $msg );

}
</pre>
<h1>Setting it up with syslog-ng</h1>
<p>If we store our POE program in <code>/usr/local/bin/poe-syslog-ng.pl</code>, in the syslog-ng.conf we need to specify it as a program:</p>
<pre class="brush: plain;">
#
# Subscriber Feeds
destination d_subscribers {
	program(&quot;/usr/local/bin/poe-syslog-ng.pl&quot;);
};
</pre>
<p>Then you can feed it based on filters, just like the rest of the <code>destination</code> macros in syslog-ng:</p>
<pre class="brush: plain;">
#
# SUBSCRIPTION SERVICE:
log { source(s_ext); source(s_udp); filter(f_database); destination(d_subscribers); };
</pre>
<h1>The whole #! </h1>
<p>For those interested, I&#8217;ve written a program that expands this example with enhanced functionality.  The full source is available here:</p>
<pre class="brush: perl; collapse: true; light: false; toolbar: true;">
#!/usr/bin/perl
#
# This is the POE Master Server.
#  1) Take all the syslog input
#  2) Listen for parsers
#  3) Filter streams to parsers
#  TODO: 4) Maintain Parser State, restarting on crash

use strict;
use warnings;

use Socket;
use Regexp::Common qw(net);

sub POE::Kernel::ASSERT_DEFAULT (){ 1 }
#sub POE::Kernel::TRACE_DEFAULT (){ 1 }
use POE qw(
	Wheel::ReadWrite
	Component::Server::TCP
);

my %cooked = (
	program =&gt; qr/\s+\d+:\d+:\d+\s+\S+\s+([^:\s]+)(:|\s)/,
);

#--------------------------------------------------------------------------#
# POE Session Initialization

# Dispatcher Master Session
POE::Session-&gt;create(
	inline_states =&gt; {
		_start					=&gt; \&amp;dispatcher_start,
		_stop					=&gt; sub { print &quot;SESSION &quot;, $_[SESSION]-&gt;ID, &quot; stopped.\n&quot;; },
		register_client			=&gt; \&amp;register_client,
		subscribe_client		=&gt; \&amp;subscribe_client,
		unsubscribe_client		=&gt; \&amp;unsubscribe_client,
		fullfeed_client			=&gt; \&amp;fullfeed_client,
		dispatch_message		=&gt; \&amp;dispatch_message,
		broadcast				=&gt; \&amp;broadcast,
		hangup_client			=&gt; \&amp;hangup_client,
		server_shutdown			=&gt; \&amp;server_shutdown,
		debug_client			=&gt; \&amp;debug_client,
		nobug_client			=&gt; \&amp;nobug_client,
		debug_message			=&gt; \&amp;debug_message,
	},
);

# TCP Session Master
POE::Component::Server::TCP-&gt;new(
		Alias		=&gt; 'server',
		Address		=&gt; '127.0.0.1',
		Port		=&gt; 9514,

		ClientConnected		=&gt; \&amp;client_connect,
		ClientInput			=&gt; \&amp;client_input,

		ClientDisconnected	=&gt; \&amp;client_term,
		ClientError			=&gt; \&amp;client_term,

		InlineStates		=&gt; {
			client_print		=&gt; \&amp;client_print,
		},
);

# Syslog-ng Stream Master
POE::Session-&gt;create(
		inline_states =&gt; {
			_start		=&gt; \&amp;stream_start,
			_stop		=&gt; sub { print &quot;SESSION &quot;, $_[SESSION]-&gt;ID, &quot; stopped.\n&quot;; },

			stream_line		=&gt; \&amp;stream_line,
			stream_error	=&gt; \&amp;stream_error,
		},
);

#--------------------------------------------------------------------------#

#--------------------------------------------------------------------------#
# POE Main Loop
POE::Kernel-&gt;run();
exit 0;
#--------------------------------------------------------------------------#

#--------------------------------------------------------------------------#
# POE Event Functions
#--------------------------------------------------------------------------#

#--------------------------------------------------------------------------#
sub debug {
	my $msg = shift;
	chomp($msg);
	$poe_kernel-&gt;post( 'dispatcher' =&gt; 'debug_message' =&gt; $msg );
	print &quot;[debug] $msg\n&quot;;
}
#--------------------------------------------------------------------------#
sub dispatcher_start {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel-&gt;alias_set( 'dispatcher' );

	$heap-&gt;{subscribers} = { };
	$heap-&gt;{full} = { };
	$heap-&gt;{debug} = { };
}

#--------------------------------------------------------------------------#
sub register_client {
	my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

	$heap-&gt;{clients}{$sid} = 1;
}

#--------------------------------------------------------------------------#
sub debug_client {
	my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

	if( exists $heap-&gt;{full}{$sid} ) {  return;  }

	$heap-&gt;{debug}{$sid} = 1;
	$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Debugging enabled.' );
}

#--------------------------------------------------------------------------#
sub nobug_client {
	my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

	delete $heap-&gt;{debug}{$sid}
		if exists $heap-&gt;{debug}{$sid};
	$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Debugging disabled.' );
}

#--------------------------------------------------------------------------#
sub fullfeed_client {
	my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

	#
	# Remove from normal subscribers.
	foreach my $prog (keys %{ $heap-&gt;{subscribers} }) {
		delete $heap-&gt;{subscribers}{$prog}{$sid}
			if exists $heap-&gt;{subscribers}{$prog}{$sid};
	}

	#
	# Turn off DEBUG
	if( exists $heap-&gt;{debug}{$sid} ) {
		delete $heap-&gt;{debug}{$sid};
	}

	#
	# Add to fullfeed:
	$heap-&gt;{full}{$sid} = 1;

	$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Full feed enabled, all other functions disabled.');
}

#--------------------------------------------------------------------------#
sub subscribe_client {
	my ($kernel,$heap,$sid,$argstr) = @_[KERNEL,HEAP,ARG0,ARG1];

	if( exists $heap-&gt;{full}{$sid} ) {  return;  }

	my @progs = map { lc } split /[\s,]+/, $argstr;
	foreach my $prog (@progs) {
		$heap-&gt;{subscribers}{$prog}{$sid} = 1;
	}

	$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Subscribed to : ' . join(', ', @progs ) );
}
#--------------------------------------------------------------------------#
sub unsubscribe_client {
	my ($kernel,$heap,$sid,$argstr) = @_[KERNEL,HEAP,ARG0,ARG1];

	my @progs = map { lc } split /[\s,]+/, $argstr;
	foreach my $prog (@progs) {
		delete $heap-&gt;{subscribers}{$prog}{$sid};
	}

	$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Subscription removed for : ' . join(', ', @progs ) );
}

#--------------------------------------------------------------------------#
sub hangup_client {
	my ($kernel,$heap,$sid) = @_[KERNEL,HEAP,ARG0];

	delete $heap-&gt;{clients}{$sid};

	foreach my $p ( keys %{ $heap-&gt;{subscribers} } ) {
		delete $heap-&gt;{subscribers}{$p}{$sid}
			if exists $heap-&gt;{subscribers}{$p}{$sid};
	}

	if( exists $heap-&gt;{debug}{$sid} ) {
		delete $heap-&gt;{debug}{$sid};
	}

	if( exists $heap-&gt;{full}{$sid} ) {
		delete $heap-&gt;{full}{$sid};
	}

	debug(&quot;Client Termination Posted: $sid\n&quot;);

}

#--------------------------------------------------------------------------#
sub stream_start {
	my ($kernel, $heap) = @_[KERNEL, HEAP];

	$kernel-&gt;alias_set( 'stream' );

	#
	# Initialize the connection to STDIN as a POE::Wheel
	my $stdin = IO::Handle-&gt;new_from_fd( \*STDIN, 'r' );
	my $stderr = IO::Handle-&gt;new_from_fd( \*STDERR, 'w' );

	$heap-&gt;{stream} = POE::Wheel::ReadWrite-&gt;new(
		InputHandle		=&gt; $stdin,
		OutputHandle	=&gt; $stderr,
		InputEvent		=&gt; 'stream_line',
		ErrorEvent		=&gt; 'stream_error',
	);
}

#--------------------------------------------------------------------------#
sub stream_line {
	my ($kernel,$msg) = @_[KERNEL,ARG0];

	return unless length $msg;

	$kernel-&gt;post( 'dispatcher' =&gt; 'dispatch_message' =&gt; $msg );

}

#--------------------------------------------------------------------------#
sub stream_error {
	my ($kernel) = $_[KERNEL];

	debug(&quot;STREAM ERROR!!!!!!!!!!\n&quot;);
	$kernel-&gt;call( 'dispatcher' =&gt; 'server_shutdown' =&gt; 'Stream lost' );
}

#--------------------------------------------------------------------------#
sub server_shutdown {
	my ($kernel,$heap,$msg) = @_[KERNEL,HEAP,ARG0];

	$kernel-&gt;call( dispatcher =&gt; 'broadcast' =&gt; 'SERVER DISCONNECTING: ' . $msg );
	$kernel-&gt;call( 'server' =&gt; 'shutdown' );
	exit;
}

#--------------------------------------------------------------------------#
sub client_connect {
	my ($kernel,$heap,$ses) = @_[KERNEL,HEAP,SESSION];

	my $KID = $kernel-&gt;ID();
	my $CID = $heap-&gt;{client}-&gt;ID;
	my $SID = $ses-&gt;ID;

	$kernel-&gt;post( 'dispatcher' =&gt; 'register_client' =&gt; $SID );

	$heap-&gt;{clients}{ $SID } = $heap-&gt;{client};
	#
	# Say hello to the client.
	$heap-&gt;{client}-&gt;put( &quot;EHLO Streamer (KERNEL: $KID:$SID)&quot; );
}

#--------------------------------------------------------------------------#
sub client_print {
	my ($kernel,$heap,$ses,$mesg) = @_[KERNEL,HEAP,SESSION,ARG0];

	$heap-&gt;{clients}{$ses-&gt;ID}-&gt;put($mesg);
}

#--------------------------------------------------------------------------#
sub broadcast {
	my ($kernel,$heap,$msg) = @_[KERNEL,HEAP,ARG0];

	foreach my $sid (keys %{ $heap-&gt;{clients} }) {
		$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; $msg );
	}
}
#--------------------------------------------------------------------------#
sub dispatch_message {
	my ($kernel,$heap,$msg) = @_[KERNEL,HEAP,ARG0];

	foreach my $sid ( keys %{ $heap-&gt;{full} } ) {
		$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; $msg );
	}

	if( my ($program) = map { lc } ($msg =~ /$cooked{program}/) ) {
		# remove the sub process and PID from the program
		$program =~ s/\(.*//g;
		$program =~ s/\[.*//g;

		debug(&quot;DISPATCHING MESSAGE [$program]&quot;);

		if( exists $heap-&gt;{subscribers}{$program} ) {
			foreach my $sid (keys %{ $heap-&gt;{subscribers}{$program} }) {
				$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; $msg );
			}
		}
		else {
			debug(&quot;Message discarded, no listeners.&quot;);
		}
	}
	else {
			debug(&quot;Message discarded, format not understood.&quot;);
	}
}

#--------------------------------------------------------------------------#
sub debug_message {
	my ($kernel,$heap,$msg) = @_[KERNEL,HEAP,ARG0];

	foreach my $sid (keys %{ $heap-&gt;{debug} }) {
		$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; '[debug] ' . $msg );
	}
}

#--------------------------------------------------------------------------#
sub client_input {
	my ($kernel,$heap,$ses,$msg) = @_[KERNEL,HEAP,SESSION,ARG0];
	my $sid = $ses-&gt;ID;

	if( !exists $heap-&gt;{dispatch}{$sid} ) {
		$heap-&gt;{dispatch}{$sid} = {
			fullfeed		=&gt; {
				re			=&gt; qr/^(fullfeed)/,
				callback	=&gt; sub {
					$kernel-&gt;post( 'dispatcher' =&gt; 'fullfeed_client' =&gt; $sid );
				},
			},
			subscribe		=&gt; {
				re			=&gt; qr/^sub(?:scribe)? (.*)/,
				callback	=&gt; sub {
					$kernel-&gt;post( 'dispatcher' =&gt; 'subscribe_client' =&gt; $sid, shift );
				},
			},
			unsubscribe 	=&gt; {
				re			=&gt; qr/^unsub(?:scribe)? (.*)/,
				callback	=&gt; sub {
					$kernel-&gt;post( 'dispatcher' =&gt; 'unsubscribe_client' =&gt; $sid, shift );
				},
			},
			debug 	=&gt; {
				re			=&gt; qr/^(debug)/i,
				callback	=&gt; sub {
					$kernel-&gt;post( 'dispatcher' =&gt; 'debug_client' =&gt; $sid, shift );
				},
			},
			nobug 	=&gt; {
				re			=&gt; qr/^(no(de)?bug)/i,
				callback	=&gt; sub {
					$kernel-&gt;post( 'dispatcher' =&gt; 'nobug_client' =&gt; $sid, shift );
				},
			},
			#quit			=&gt; {
			#	re			=&gt; qr/(exit)|q(uit)?/,
			#	callback	=&gt; sub {
			#			$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'Terminating connection on your request.');
			#			$kernel-&gt;post( $sid =&gt; 'shutdown' );
			#	},
			#},
			#status			=&gt; {
			#	re			=&gt; qr/^status/,
			#	callback	=&gt; sub {
			#		my $cnt = scalar( keys %{ $heap-&gt;{clients} } );
			#		my $subcnt = scalar( keys %{ $heap-&gt;{subscribers} });
			#		my $msg = &quot;Currently $cnt connections, $subcnt subscribed.&quot;;
			#		$kernel-&gt;post( $sid, 'client_print', $msg );
			#	},
			#},
		};
	}

	#
	# Check for messages:
	my $handled = 0;
	my $dispatch = $heap-&gt;{dispatch}{$sid};
	foreach my $evt ( keys %{ $dispatch } ) {
		if( my($args) = ($msg =~ /$dispatch-&gt;{$evt}{re}/)) {
			$handled = 1;
			$dispatch-&gt;{$evt}{callback}-&gt;($args);
			last;
		}
	}

	if( !$handled ) {
		$kernel-&gt;post( $sid =&gt; 'client_print' =&gt; 'UNKNOWN COMMAND, Ignored.' );
	}
}

#--------------------------------------------------------------------------#
sub client_term {
	my ($kernel,$heap,$ses) = @_[KERNEL,HEAP,SESSION];
	my $sid = $ses-&gt;ID;

	delete $heap-&gt;{dispatch}{$sid};
	$kernel-&gt;post( 'dispatcher' =&gt; 'hangup_client' =&gt;  $sid );

	debug(&quot;SERVER, client $sid disconnected.\n&quot;);
}

#--------------------------------------------------------------------------#
</pre>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2009/07/02/using-poe-to-hook-syslog-ng/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>YAPC::NA 10th Anniversary Wrap Up Post</title>
		<link>http://divisionbyzero.net/blog/2009/06/26/yapcna-10th-anniversary-wrap-up-post/</link>
		<comments>http://divisionbyzero.net/blog/2009/06/26/yapcna-10th-anniversary-wrap-up-post/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 18:11:38 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[yapc]]></category>
		<category><![CDATA[yapc10]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=117</guid>
		<description><![CDATA[I got back from YAPC::NA #10 yesterday. There was a lot of sleeping required to recover from a tech conference with 8 am talks! A Twitter Search for &#8220;yapc&#8221; indicates I&#8217;m not the only one slow to recover those missing hours of sleep. Overall the conference was a fantastic success. There were highs and lows, [...]]]></description>
			<content:encoded><![CDATA[<p>I got back from <a href="http://yapc10.org/" alt="YAPC::NA 10">YAPC::NA #10</a> yesterday.  There was a lot of sleeping required to recover from a tech conference with 8 am talks!  A <a href="http://twitter.com/#search?q=yapc" alt="twitter search yapc">Twitter Search for &#8220;yapc&#8221;</a> indicates I&#8217;m not the only one slow to recover those missing hours of sleep.</p>
<p>Overall the conference was a fantastic success.  There were highs and lows, and I just wanted to take an opportunity to thank the conference organizers!! They did a wonderful job putting together another spectacular conference.</p>
<p>Also wanted to thank all the speakers as I know firsthand how much work goes into presenting at a conference like YAPC.  All the talks I attended were great, however several stood out as exceptional:</p>
<ul>
<li><a href="http://yapc10.org/yn2009/talk/1960" alt="Trapped in a Room with Schwern">Trapped in a Room with Schwern</a> &#8211; Michael Schwern is an excellent speaker, and this free room talk with back and forth between him and members of the community at all levels of mastery provided insight into projects I was unaware of, as well as some relief that most of my concerns about Perl 5 were being discussed by people far smarter than myself.</li>
<li><a href="http://yapc10.org/yn2009/talk/1975" alt="The Future of DBIx::Class">The Future of DBIx::Class</a> &#8211; Matt S Trout (MST) is a speaker for the real programmers.  His volume, accent, and excessive use of profanity actually keep people listening.  Getting yelled at by Matt Trout was the highlight of this conference for me.  He has good ideas and opinions and he&#8217;s not afraid to beat them into your head.  Kid gloving is great for Managers, but his presentation style and content really clicks with the people who don&#8217;t have their heads so far up their own asses to understand things need to change.  Excellent talk about the past, present, and future of DBIx::Class which is the most significant ORM in the Perl Community currently.</li>
<li><a href="http://yapc10.org/yn2009/talk/1983" alt="Take Advantage of Modern Perl">Take Advantage of Modern Perl</a> &#8211; chromatic&#8217;s speaking style is the complete opposite of MST&#8217;s, but his message synced with Schwern, MST, and the <a href="http://enlightenedperl.org" alt="The Enlightened Perl Organisation">The Enlightened Perl Organisation</a>: Encourage people to write better Perl.  Write Better Perl.  Teach others how to write better Perl.  Embrace the language where it is now, and transition away from the bad things in the past.  Fantastic Talk.</li>
<li><a href="http://yapc10.org/yn2009/talk/2155" alt="perl5i: Perl 5 Imporved">perl5i: Perl 5 Improved</a> &#8211; Michael Schwern echoing chromatic&#8217;s plea for leveraging the best of what Perl 5 offers today.  He&#8217;s got a module on cpan, <a href="http://github.com/schwern/perl5i/tree/master" alt="perl5i @ github">perl5i</a>, which implements the best of Perl 5 Tribal Knowledge.</li>
<li><a href="http://yapc10.org/yn2009/talk/1978" alt="Catching an ::Std">Catching an ::Std</a> &#8211; MST again.  He very honestly covered the trials, tribulations, and evolution of &#8220;Best Practices&#8221; in the Perl community.</li>
<li><a href="http://yapc10.org/yn2009/talk/2012" alt="CGI::Inspect">Drop in REPL for CGI Applications</a> &#8211; Brock Wilcox floored everyone demonstrating his ridiculously cool module <a href="http://search.cpan.org/~awwaiid/CGI-Inspect-0.4/">CGI::Inspect</a>.  I went in expecting &#8220;neat&#8221; and found &#8220;amazing.&#8221;  We&#8217;ll be abusing this in development very soon.</li>
</ul>
<p>These were my favorite talks, but like I said, every talk I went to was fantastic.  I did miss a few talks I wanted to see due to schedule conflicts, but I&#8217;ll be checking the YAPC website for slides and video/audio.  The conference organizers were not able to record anything, but a few attendees brought recording equipment with them.  If nothing else, I&#8217;ll hopefully see those missed talks next year or at the <a href="http://pghpw.org/">Pittsburgh Perl Workshop</a> in 2010!</p>
<p>I&#8217;m recommitting to the Perl Iron Man.  I was an idiot and jackass for bailing after 1 post! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2009/06/26/yapcna-10th-anniversary-wrap-up-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Iron Man Contest</title>
		<link>http://divisionbyzero.net/blog/2009/04/22/perl-iron-man-contest/</link>
		<comments>http://divisionbyzero.net/blog/2009/04/22/perl-iron-man-contest/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 21:20:14 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[catalyst]]></category>
		<category><![CDATA[dbix::class]]></category>
		<category><![CDATA[mst]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[poe]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=102</guid>
		<description><![CDATA[Matthew S Trout has started a Perl Iron Man challenge to encourage Perl users to become active in the blogosphere.  Not many people outside of the Perl echo chamber realize how active and modern the language.  A lot of the concepts that trampolined Ruby and Python into the forefront of Web 2.0 have been alive [...]]]></description>
			<content:encoded><![CDATA[<p><a title="MST's Iron Man Challenge" href="http://www.shadowcat.co.uk/blog/matt-s-trout/iron-man/" target="_blank">Matthew S Trout has started a Perl Iron Man challenge</a> to encourage Perl users to become active in the blogosphere.  Not many people outside of the Perl echo chamber realize how active and modern the language.  A lot of the concepts that trampolined Ruby and Python into the forefront of Web 2.0 have been alive and well in the Perl community for a long time.  With the advent of Moose, Perl5 is as serious an Object Oriented language as Python and Ruby.</p>
<p>I entered myself today.  The goal is blog about Perl atleast once a week.  As I&#8217;m splitting my development time between a Catalyst Project and a number of POE projects, I expect my posts to be along those lines.  I&#8217;ll eventually share my DBIx::Class scripts as well.  There should be something for everyone, especially @strcpy!  (He loves my Perl blogging).</p>
<p>Look for code related stuff early next week!</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2009/04/22/perl-iron-man-contest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Perl is Dead</title>
		<link>http://divisionbyzero.net/blog/2009/04/05/perl-is-dead/</link>
		<comments>http://divisionbyzero.net/blog/2009/04/05/perl-is-dead/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 00:49:47 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[catalyst]]></category>
		<category><![CDATA[dbix::class]]></category>
		<category><![CDATA[mason]]></category>
		<category><![CDATA[moose]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl::critic]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=94</guid>
		<description><![CDATA[I&#8217;ve been doing web application development for years in several languages. I&#8217;ve spent time with PHP, Java, but primarily Perl. I consider myself a &#8220;Perl Programmer&#8221; first, everything else second. Until recently, most people would equate that to &#8220;Dinosaur.&#8221; However, there&#8217;s been a revival of Perl these days! There are a number of reasons for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing web application development for years in several languages.  I&#8217;ve spent time with PHP, Java, but primarily Perl.  I consider myself a &#8220;Perl Programmer&#8221; first, everything else second.  Until recently, most people would equate that to &#8220;Dinosaur.&#8221;  However, there&#8217;s been a revival of Perl these days!  There are <a title="Movable Type, Open Source" href="http://www.movabletype.org/" target="_blank">a</a> <a title="Enlightened Perl Org" href="http://www.enlightenedperl.org/">number</a> <a title="The Perl Foundation" href="http://www.perlfoundation.org/">of</a> <a title="Perl Sphere" href="http://perlsphere.net/" target="_blank">reasons</a> <a title="Perl Buzz" href="http://perlbuzz.com/" target="_blank">for</a> <a title="Modern Perl" href="http://www.modernperlbooks.com/mt/index.html" target="_blank">this</a>.</p>
<p><span id="more-94"></span></p>
<p>It all started with the concept of &#8220;Inside Out Objects&#8221; as a safe, functional object development methodology.  From there a number of modules sprouted attempting to do Inside-Out better.   Around this time, the Perl 6 <a title="Perl 6 Apocalypses" href="http://dev.perl.org/perl6/doc/apocalypse.html" target="_blank">Apocalypses</a> were being published and translated in Conway&#8217;s <a title="Perl 6 Exegeses" href="http://dev.perl.org/perl6/doc/exegesis.html" target="_blank">Exegeses</a>.  Conway  published &#8220;<a title="Perl Best Practices" href="http://oreilly.com/catalog/9780596001735/" target="_blank">Perl Best Practices</a>&#8221; and very soon after, <a title="Perl::Critic @ The CPAN" href="http://search.cpan.org/~elliotjs/Perl-Critic-1.096/" target="_blank">Perl::Critic</a> showed up on the <a title="The CPAN" href="http://www.cpan.org" target="_blank">CPAN</a> to enforce the rules laid out in the book.  Perl::Critic became a critical authority on the most maintainable way to write Perl code.  TIMTOWTDI will never die, but clean, maintainable code does outweigh some stranger interpreter abuses.</p>
<p>The modern looking object system for Perl 6 made it debut, and instantly the Army of CPAN began figuring out clever ways to implement fancy object notation in Perl 5.  his eventually led to the development of Class::MOP, from which the &#8220;post Modern Object System for Perl 5,&#8221; Moose, blossomed.</p>
<p>Concurrently, Ruby on Rails had layed waste to the entire scope of PHP Scaffolding systems in existence, building off the Model-View-Controller (MVC) Ideology implemented earlier in Perl 5 through Maypole.  As RoR gained traction, Python&#8217;s Django framework, through it&#8217;s association with the MVC philosophy, began to see serious deployment.  This made sense as a lot of large Open Source and Commercial companies were using Python for much of their behind the scenes development.  The result left PHP staggering and dizzy in the corner.</p>
<p>Unfortunately, there was a horrible association of PHP to Perl in most people&#8217;s heads, which sounded the Death Knell for Perl as well.  This wasn&#8217;t the case, as Perl, inside it&#8217;s mostly impenetrable Echo Chamber had not stagnated at all.  Perl 5.8.x was a huge performance and syntactical modernization of Perl 5.  This improvement was eclipsed with the release of 5.10, drawing from the Perl 6 Design Documents, and the push of the Echo Chamber for a more Modern Language.</p>
<p>The Army of CPAN was still hard at work in the background throughout all of this.  ORM&#8217;s drawing on the Success of the MVC philosophy took shape and evolved.  Rose::DB, Class::DBI, and the current forerunner DBIx::Class simplified database development through the use of abstraction through modules like SQL::Abstract.  Maypole, an simplified, earlier implementation of MVC sparked other MVC efforts in Perl 5, the most popular of which are Catalyst, Jifty, and CGI::Application.  Each have their strengths and weaknesses.</p>
<p>All of these modules are beginning to converge to create a beautiful, post modern web application development platform in pure Perl.  Additionally, projects like Strawberry Perl, and Padre are aiming to expand Perl&#8217;s reach into realms it&#8217;s shied away from: Windows &amp; IDEs.  The future is bright for Perl thanks to efforts of countless volunteers and programmers.</p>
<p>Perl is dead.  Long live Perl.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2009/04/05/perl-is-dead/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pittsburgh Perl Workshop 2008</title>
		<link>http://divisionbyzero.net/blog/2008/10/15/pittsburgh-perl-workshop-2008/</link>
		<comments>http://divisionbyzero.net/blog/2008/10/15/pittsburgh-perl-workshop-2008/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 01:31:32 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ppw]]></category>
		<category><![CDATA[ppw2008]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/?p=54</guid>
		<description><![CDATA[I had the pleasure of speaking at the 2008 Pittsburgh Perl Workshop. Due to some rather depressing news on the home front, I was only able to attend Saturday&#8217;s track and the Event Dinner. Everything was awesome as usual. I was even surprised to learn new things in the Advanced Pattern Matching talk. My talk [...]]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure of speaking at the <a href="http://pghpw.org/ppw2008/">2008 Pittsburgh Perl Workshop</a>.  Due to some rather depressing news on the home front, I was only able to attend <a href="http://pghpw.org/ppw2008/schedule?day=2008-10-11">Saturday&#8217;s track</a> and the Event Dinner.  Everything was awesome as usual.  I was even surprised to learn new things in the <a href="http://pghpw.org/ppw2008/talk/1505">Advanced Pattern Matching</a> talk.</p>
<p>My talk was titled <a href="http://divisionbyzero.net/PGHPW08.pdf">Network Introspection with Open Source Tools</a> and was an overhaul of the presentation that I did at LinuxWorld earlier this year.  I took the feedback of the audience and tuned the talk to a Perl centric audience.  I wasn&#8217;t heckled badly on IRC, which is the ultimate gauge of success.</p>
<p>I&#8217;d like to thank the organizers, <a href="http://cmu.edu">CMU</a>, sponsors, and The Perl Foundation for another successful year of the Work Shop.  Next year, Pittsburgh is hosting YAPC::NA, and will not be hosting the Pittsburgh Perl Workshop.  I look forward to being able to drive to YAPC!</p>
<p>If you saw the talk and want to rant about it, feel free to do so here.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2008/10/15/pittsburgh-perl-workshop-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pittsburgh Perl Workshop 2007</title>
		<link>http://divisionbyzero.net/blog/2007/10/18/pittsburgh-perl-workshop-2007/</link>
		<comments>http://divisionbyzero.net/blog/2007/10/18/pittsburgh-perl-workshop-2007/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 22:02:53 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[ppw2007]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/2007/10/18/pittsburgh-perl-workshop-2007/</guid>
		<description><![CDATA[I&#8217;ve attended 4 Perl Conferences in the past 2 years.  This year&#8217;s Pittsburgh Perl Workshop is the first that I&#8217;ve presented at.  My talk was titled Security through Detection, Prevention, and Introspection. I have slides available. I originally wanted to present a bunch of code, but I couldn&#8217;t really find a way to make the [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve attended 4 Perl Conferences in the past 2 years.  This year&#8217;s Pittsburgh Perl Workshop is the first that I&#8217;ve presented at.  My talk was titled <span class="Apple-style-span" style="font-weight: bold; font-style: italic">Security through Detection, Prevention, and Introspection</span>. <a href="http://divisionbyzero.net/~brad/PGHPW07.pdf" alt="Slides for PGHPW07">I have slides available</a>.
</p>
<p>
I originally wanted to present a bunch of code, but I couldn&#8217;t really find a way to make the code very interesting.  I wanted to teach people that security is part of all of their jobs.  I made it a point to reveal some of the idiocy of the Federal Government Mandates in relation to IT Security.  I also gave an overview of the security system I&#8217;m building with Perl at work.
</p>
<p>
There were laughs, smiles, and a lot of people woke up.  All in all, I&#8217;d say it went very well.  I&#8217;d like to refine the presentation and possibly resubmit for <a href="http://yapc.org" alt="YAPC Website">YAPC::NA</a> this year.  Bigger audience, and an opportunity for me to conquer a large slice of my stage fright.
</p>
<p>
If anyone out there reading this saw the presentation and has feedback, please comment on this post!
</p>
<p>
<strong>UPDATE:</strong>  If you enjoyed the content of my talk on security, please check out these articles I&#8217;ve written:</p>
<ul>
<li><a href="http://divisionbyzero.net/blog/2006/07/12/trust/" alt="Trust">Trust</a> &#8211; Paradoxical Structure of Trust in Employers</li>
<li><a href="http://divisionbyzero.net/blog/2006/07/18/eating-your-own-dog-food/" alt="Eating Your Own Dog Food">Eating Your Own Dog Food</a> &#8211; Hypocritical IT Security Policies In the Real World</li>
<li><a href="http://divisionbyzero.net/blog/2006/08/21/full-disk-encryption/" alt="FDE">Full Disk Encryption</a> &#8211; In Theory and Practice</li>
<li><a href="http://divisionbyzero.net/blog/2006/10/31/is-security-theatre-good-enough/" alt="Is Security Theatre Good Enough?">Is Security Theatre Good Enough?</a> Frustrating observations into poor Risk Analysis in the general populace.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2007/10/18/pittsburgh-perl-workshop-2007/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP, Are you serious?</title>
		<link>http://divisionbyzero.net/blog/2006/07/26/php-are-you-serious/</link>
		<comments>http://divisionbyzero.net/blog/2006/07/26/php-are-you-serious/#comments</comments>
		<pubDate>Thu, 27 Jul 2006 03:55:44 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/2006/07/26/php-are-you-serious/</guid>
		<description><![CDATA[A long time ago, in a galaxy far, far away, I programmed in PHP for a mortgage company. I ended up leaving that job for personal reasons. Apparently, 40 hours/week truly is not enough. I was a Perl programmer prior to that excursion, and I guess I never grew out of it. I always felt [...]]]></description>
			<content:encoded><![CDATA[<p>A long time ago, in a galaxy far, far away, I programmed in <a title="PHP Site" href="http://www.php.net">PHP</a> for a mortgage company.  I ended up leaving that job for personal reasons.  Apparently, 40 hours/week truly is not enough.  I was a Perl programmer prior to that excursion, and I guess I never grew out of it.  I always felt uncomfortable there.  For a while I thought it might be social, but after further reflection, it&#8217;s obvious it was actually PHP&#8217;s fault.</p>
<p>To frame this, I just got back from <a title="YAPC::NA Chicago" href="http://www.yapcchicago.org">YAPC::NA</a>.  I learned all kinds of new techniques and tricks from MJD, chromatic, brian d. foy, Randal Schwartz, Damian Conway, and countless other acquaintances.  What&#8217;s not to love about <a title="Mason Headquarters" href="http://www.masonhq.com">Mason</a>, <a title="DBIx::Class" href="http://search.cpan.org/~jrobinson/DBIx-Class-0.06003/lib/DBIx/Class.pm">DBIx::Class</a>, and the brain bending functional tricks you can learn from MJD and chromatic?  I never knew that @INC could contain a subroutine reference, did you?  I also never thought of something so clever as recursively calling an anonymous sub ref contained in a scalar by using another anonymous subroutine that dereferences that ref at runtime.</p>
<p><span id="more-13"></span> So now, after refactoring a TON of my code to <a title="PBP @ O'Reilly" href="http://www.oreilly.com/catalog/perlbp/index.html">Perl Best Practices</a>, I&#8217;m back into the land of PHP temporarily.  Our administration group at work is looking for a project tracking system.  After favorable experiences with <a title="dotProject Homepage" href="http://www.dotproject.net">dotProject</a> a year ago, I suggested that.  I hadn&#8217;t touched dotProject or PHP since dotProject&#8217;s 1.x branch.  They&#8217;re now at 2.0.4 and it seems there just might be a few more hands in the pot.  The code is not as coherent and refreshing as I remember it.</p>
<p>I&#8217;ve been spending time building a module for additional &#8220;fund&#8221; tracking.  PHP seriously gets in my way.  Granted, I have a very heavy bias against anything but Perl, but my god, there&#8217;s a reason why <a title="Google :: " href="http://www.google.com/search?q=php%20sucks">this Google Search</a> exists.  They&#8217;re not lying.  I&#8217;m dealing with PHP4, so perhaps PHP5 has gotten better, but I harbor serious doubt that even by getting &#8220;better&#8221; that PHP5 would approach anything a serious computer scientist / programmer would consider usable.</p>
<p>The language is a patchwork of functions.  There&#8217;s no real defining factor or consistency.   As a matter of fact, the only thing consistent is the fact that regardless of what library in PHP you&#8217;re using, chances are the function names and argument orders lack consistency in that module and in the whole picture.</p>
<p>Don&#8217;t get me wrong, PHP is great for web designers and novices.  There&#8217;s a very low barrier to entry.  However, we now have a landscape littered with horrible PHP applications that expose servers to vicious attacks from outsiders.  PHP is not by any means a language that should be taken seriously by any serious developer.  Please invest your time elsewhere.  I&#8217;d even recommend Python over PHP.  Ruby would be a more worthwhile excursion.</p>
<p>PHP makes simple things simple and hard and obscure.  Hard things are impossible.  The biggest hole in the language from the perspective of a Perl or Lisp programmer is the complete lack of lexical scope.  I know, inside of a function there&#8217;s a lexical scope, but it&#8217;s not really a lexical scope, it&#8217;s a hack.  You  have your choice between global scoped variables, or variables scoped inside of a function.  No other closure provides an effective measure to force destruction and garbage clean up.  More importantly, certain techniques become ridiculous without proper lexical scope.</p>
<p>Early version of PHP3, maybe even &#8220;late&#8221; versions, had no scoping even for functions.  This became a problem to anyone used to using recursion to solve recursive problems.  Recursion relies on the fact that each call to the function can resolve independantly of the rest of the call stack.  Modifying variables that are still in wait on the stack can cause some &#8220;unexpected&#8221; behavior.</p>
<p>There also seems to be a problem with ternary operators.  Unexplainably, if the false condition of a ternary construct is in itself another ternary, the false is evaluated.  In order to &#8220;nest&#8221; ternary operators, <a title="Aboslute Bullshit Nested ternary operators." href="http://us2.php.net/manual/en/language.operators.comparison.php#56572">you need to enclose each INDIVIDUAL ternary in its own set of parentheses</a>.  Find precident for that illogical BS.  Why in the hell are we evaluating the false condition if the current ternary operator has returned &#8220;true&#8221; ?</p>
<p>It&#8217;s been a painful process, but in order to program in PHP, I&#8217;ve learned that you absolutely need a function reference.  It is impossible for a human being to formulate a logical function naming convention (is it &#8220;noun then verb? verb than noun? do I separate with underscores, or just smash it together&#8221;?) let alone the argument order even inside the same &#8220;module&#8221;.  Just peruse the <a title="PHP Function Reference" href="http://us2.php.net/manual/en/funcref.php">function reference on the php.net site</a> to see what I&#8217;m talking about.  Zero consistency.  Please, pick an interface and stick with it.</p>
<p>Bottom line, PHP is a good place to start, but don&#8217;t stop there.  Pick up another language.  I recommend Perl.  I&#8217;ll even teach you.  I&#8217;m gonna be teaching at NIH in the near future and I&#8217;ll be sharing my course material here.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2006/07/26/php-are-you-serious/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>YAPC::NA &#8211; Impressions</title>
		<link>http://divisionbyzero.net/blog/2006/07/17/yapcna-impressions/</link>
		<comments>http://divisionbyzero.net/blog/2006/07/17/yapcna-impressions/#comments</comments>
		<pubDate>Tue, 18 Jul 2006 01:36:19 +0000</pubDate>
		<dc:creator>brad</dc:creator>
				<category><![CDATA[Note]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://divisionbyzero.net/blog/2006/07/17/yapcna-impressions/</guid>
		<description><![CDATA[I&#8217;ve been bugging my employers for years to send me to conferences and training seminars. None of them have been keen on the idea, and it&#8217;s a real shame. I&#8217;m lucky enough to have an incredibly good supervisory staff and a great job now. I asked to go to YAPC::NA, and they decided it would [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been bugging my employers for years to send me to conferences and training seminars.  None of them have been keen on the idea, and it&#8217;s a real shame.  I&#8217;m lucky enough to have an incredibly good supervisory staff and a great job now.  I asked to go to <a title="YAPC::NA 2006 - Chicago" href="http://www.yapcchicago.org">YAPC::NA</a>, and they decided it would be a good idea to send me!</p>
<p>I can honestly say that they got their money&#8217;s worth within just a few presentations.  I also met a lot of cool people that were genuinely interested in my work.  This is encouraging me to start writing more as well as refactor my code and start a real open source project that currently is unnamed.</p>
<p>I&#8217;ll be providing a write up of my notes in a series of YAPC::NA installments.  I know it&#8217;s nearly a month after, but I was so excited, I spent my time actually implementing new things at work based on what I learned.</p>
]]></content:encoded>
			<wfw:commentRss>http://divisionbyzero.net/blog/2006/07/17/yapcna-impressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
