<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Perls Of Wisdom</title>
	
	<link>http://www.perlsofwisdom.net</link>
	<description>Programming and Business</description>
	<lastBuildDate>Fri, 25 Nov 2011 02:23:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/PerlsOfWisdom" /><feedburner:info uri="perlsofwisdom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>PerlsOfWisdom</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>A GrandChild Theme by Any Other Name</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/vXgnRzWe3BQ/</link>
		<comments>http://www.perlsofwisdom.net/2011/11/a-grandchild-theme-by-any-other-name/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 02:23:14 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=92</guid>
		<description><![CDATA[Change the scheduled year]]></description>
			<content:encoded><![CDATA[<p>Change the scheduled year</p>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/vXgnRzWe3BQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2011/11/a-grandchild-theme-by-any-other-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2011/11/a-grandchild-theme-by-any-other-name/</feedburner:origLink></item>
		<item>
		<title>Choosing a Theme Framework</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/p4e7V5z074o/</link>
		<comments>http://www.perlsofwisdom.net/2011/11/choosing-a-theme-framework/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 01:38:51 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=90</guid>
		<description><![CDATA[Change the scheduled year]]></description>
			<content:encoded><![CDATA[<p>Change the scheduled year</p>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/p4e7V5z074o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2011/11/choosing-a-theme-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2011/11/choosing-a-theme-framework/</feedburner:origLink></item>
		<item>
		<title>Perl Wiki Updates</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/C1O9xXm_Ve0/</link>
		<comments>http://www.perlsofwisdom.net/2011/01/perl-wiki-updates/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 01:25:34 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[perl wiki]]></category>
		<category><![CDATA[socialtext]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=294</guid>
		<description><![CDATA[A couple of folks from the Perl Wiki, Luke and Audrey, dropped by. They seem like really nice people. Zbigniew, thanks for you recommendations on working with socialtext. This will save a lot of time. It looks like a couple of my big ticket items are coming soon: wiki style links and syntax highlighting Once [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of folks from the <a href="https://www.socialtext.net/perl5">Perl Wiki</a>, Luke and Audrey, dropped by.  They seem like really nice people.  Zbigniew, thanks for you recommendations on working with socialtext.  This will save a lot of time.</p>
<p>It looks like a couple of my big ticket items are coming soon:</p>
<ul>
<li>wiki style links and</li>
<li>syntax highlighting</li>
</ul>
<p>Once these are available, I&#8217;ll start writing up the articles I&#8217;m interested in.  I hope others will jump in too.</p>
<p>I was going to say something pithy, like <em>blogging can make a difference</em>, but that&#8217;s not right at all.  I made a couple of observations and some folks stepped up to the plate.  I&#8217;m cautiously optimistic about this.</p>
<p>I&#8217;ve been spending a bit of time hunting spam which, as with most wikis, is pretty easy.  First of all, I check the <a href="https://www.socialtext.net/perl5?action=recent_changes">What&#8217;s new</a> link.  Then anything that has been edited recently by someone I don&#8217;t recognise, I check and revert to a previous revision if necessary.</p>
<p>On the downside, I&#8217;ve missed the ironman schedule, dang it.</p>
<h2>Note To Self</h2>
<ul>
<li>Investigate <a href="https://www.socialtext.net/open/index.cgi?wikrad">wikirad</a> and wikedit</li>
</ul>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/C1O9xXm_Ve0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2011/01/perl-wiki-updates/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2011/01/perl-wiki-updates/</feedburner:origLink></item>
		<item>
		<title>Perl Wiki Discussion Summary</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/QLvocAbRo90/</link>
		<comments>http://www.perlsofwisdom.net/2011/01/perl-wiki-discussion-summary/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 01:51:56 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[perl wiki]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=285</guid>
		<description><![CDATA[Thanks to everyone who responded to my perl wiki post. The responses have been enlightening. A number of people pointed me at the official perl wiki which I came across when I originally searched for perl wiki. The first couple of links I clicked on led me to believe that it was mostly abandoned. On [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to everyone who responded to my perl wiki post.  The responses have been enlightening.</p>
<p>A number of people pointed me at the official <a href="https://www.socialtext.net/perl5/index.cgi?perl_5_wiki">perl wiki</a> which I came across when I originally searched for <em>perl wiki</em>.  The first couple of links I clicked on led me to believe that it was mostly abandoned.</p>
<p>On a second viewing, it <em>is</em> more actively updated than I first believed.  In the &quot;What&#8217;s New&quot; tab there are 20 updates by various folks since the 20th of December.  That&#8217;s not a big number, but it is much better than expected.  And it is more than the total number of editors of my (non-existent) wiki.</p>
<p>Looking back to 2007, Schwern&#8217;s <a href="http://use.perl.org/~schwern/journal/33765">announcement</a> was pretty inspiring.  Why didn&#8217;t it take off in the same way as the <a href="http://www.emacswiki.org/">emacswiki</a>?</p>
<h2>Some of my Current Issues with Perl Wiki</h2>
<ul>
<li>www.socialtext.org isn&#8217;t a perl url.  wiki.perl.org as suggested by Phaylon (or www.perlwiki.something) would be better.</li>
<li>I couldn&#8217;t see a way to get syntax highlighting</li>
<li>it doesn&#8217;t have pretty wikipedia-style links.  By that I mean URLs are of the form blah/blah/blah/<em>index.cgi</em>?<strong>page_name</strong> rather than blah/blah/blah/<strong>page_name</strong>.</li>
</ul>
<p>Still, when I weigh that against the fact that there are already other active editors and material which has been indexed by the search engines, it is clearly a better use of my time to become an editor than to try to get yet another perl wiki off the ground.</p>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/QLvocAbRo90" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2011/01/perl-wiki-discussion-summary/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2011/01/perl-wiki-discussion-summary/</feedburner:origLink></item>
		<item>
		<title>Searching for Programming Answers</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/O2VQeW3W6h8/</link>
		<comments>http://www.perlsofwisdom.net/2010/12/searching-for-programming-answers/#comments</comments>
		<pubDate>Mon, 27 Dec 2010 23:42:32 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=267</guid>
		<description><![CDATA[If you have a programming problem that you can&#8217;t solve yourself, what are your options? Ask your local guru Post your question in one of hundreds of forums Search for the answer using your favourite search engine. and, for semi-completeness&#8230; &#8230;give up Of these options, using a search engine is the most popular. Many developers [...]]]></description>
			<content:encoded><![CDATA[<p>If you have a programming problem that you can&#8217;t solve yourself, what are your options?</p>
<ul>
<li>Ask your local guru</li>
<li>Post your question in one of hundreds of forums</li>
<li>Search for the answer using your favourite search engine.  and, for semi-completeness&#8230;</li>
<li>&#8230;give up</li>
</ul>
<p>Of these options, using a search engine is the most popular.  Many developers aren&#8217;t fortunate enough to have an accessible guru and formulating a question that is good enough for a forum is a lot harder than typing a few words into a search engine textbox.  In addition, it opens you up to ridicule and/or RTFM responses that you just don&#8217;t get with search.</p>
<h2>What do Programmers Search for?</h2>
<p class="first">Brian d Foy reasonably <a href="http://www.perlsofwisdom.net/2010/12/it-is-time-for-a-high-quality-perl-wiki/#comment-355">points out</a> that <a href="http://perldoc.perl.org/">the perl documentation</a> ranks highly for <em>&quot;perl documentation&quot;</em>.  But it&#8217;s not important.  No-one is searching for that anyway.
<p>Google provide some tools to check the approximate volume for a particular search.  There are 80 &#8211; 90 thousand global searches for perl documentation per month, mainly in the form of <em>&quot;perldoc&quot;</em> or <em>&quot;perl doc&quot;</em>.</p>
<p><a href="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/perl-documentation.png"><img src="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/perl-documentation-300x188.png" alt="" title="perl documentation" width="300" height="188" class="size-medium wp-image-276" /></a></p>
<p>Compare that against the number of monthly searches for <em>&quot;tcpserver&quot;</em> which is approximately 30,000.  And that is just one problem out of tens or hundreds of thousands<sup><a class="footref" name="fnr.1" href="#fn.1">1</a></sup>.</p>
<p><a href="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/tcpserver.png"><img src="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/tcpserver-300x144.png" alt="" title="tcpserver" width="300" height="144" class="size-medium wp-image-273" /></a></p>
<p>Many more people are looking for the answer to a specific problem than for perl documentation.  This makes perfect sense.</p>
<h2>What type of person is searching for &quot;perl documentation&quot; ?</h2>
<ul>
<li>People in the process of learning perl</li>
<li>People considering learning perl (probably as one of a number of options) and wondering if there is good online documentation</li>
</ul>
<p>In neither of those cases do we need to improve things.  They will find the excellent perl documentation and realise that perl is a great choice of language.</p>
<p>People looking to solve a particular problem are obviously not searching for <em>&quot;perl documentation&quot;</em>.  Aside from research for this article, <em>as an experienced perl developer</em> I haven&#8217;t needed to search for &quot;perl documentation&quot; for many years.  Having said that, I do search for &quot;perldoc [specific term]&quot; several times a month.</p>
<hr/>
<p class="footnote"><a class="footnum" name="fn.1" href="#fnr.1">1.</a> &quot;Read File&quot; gets 673,000 searches a month.  &quot;PHP Read File&quot; gets 40,500.  In comparison the number of searches specifically for the perl documentation is vanishingly small.</p>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/O2VQeW3W6h8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2010/12/searching-for-programming-answers/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2010/12/searching-for-programming-answers/</feedburner:origLink></item>
		<item>
		<title>It is Time for a High Quality Perl Wiki</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/vvDpM8VPH1I/</link>
		<comments>http://www.perlsofwisdom.net/2010/12/it-is-time-for-a-high-quality-perl-wiki/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 01:09:22 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[marketing perl]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=250</guid>
		<description><![CDATA[Perl is my preferred language for getting things done. Why? Firstly because I already know it and secondly because I know where to look for answers. When I started learning Perl, there was only one obvious choice of scripting language. Now finally there is some real competition1, but with a modern object system, fantastic (and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/encyclopedias.jpg"><img src="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/encyclopedias.jpg" alt="" title="encyclopedias" width="320" height="247" class="aligncenter size-full wp-image-259" /></a></p>
<p>Perl is my preferred language for <em>getting things done</em>.  Why?  Firstly because I already know it and secondly because I know where to look for answers.</p>
<p>When I started learning Perl, there was only one obvious choice of scripting language.  Now finally there is some real competition<sup><a class="footref" name="fnr.1" href="#fn.1">1</a></sup>, but with a <a href="http://www.iinteractive.com/moose/">modern object system</a>, <a href="http://www.onyxneon.com/books/modern_perl/index.html">fantastic (and free) books</a> and great libraries such as <a href="http://plackperl.org/">Plack</a>, Perl is still the king.</p>
<p>Gabor Szabo asks <a href="http://szabgab.com/blog/2010/12/helping-people-not-yet-in-the-perl-community.html">how we can reach</a> the 400,000 perl developers who are not yet part of the community.  His proposal is to frequent programming forums and answer newbie perl questions.</p>
<p>Answering questions one at a time on a forum by forum basis a lot of hard work.  If we&#8217;re already doing the work, it would be better to put it into making a centralized, authoritative resource &#8211; a wiki.  Programmers already know how to find out the answers to questions.  They use their <a href="http://www.duckduckgo.com">favourite search engine</a>.</p>
<p>The wiki would be maintained by the community.  It would only contain high quality modern perl code and would have plenty of inbound links.  When anyone searches for a reasonable perl question that doesn&#8217;t already have a good answer on a perl expert&#8217;s blog, a link to the wiki should appear at the top of the search engine results.</p>
<p>Talk is cheap so let me go a step further.  I&#8217;m happy to set something up if folks think this a good idea.  If a leading member of the community wants to head this up instead, then that is fine by me too.</p>
<p>Let me know in the comments.</p>
<hr/>
<p class="footnote"><a class="footnum" name="fn.1" href="#fnr.1">1.</a> From Ruby obviously.  Python was never a contender</p>
<div class="attribution">Encyclopedias by <a href="http://www.flickr.com/photos/icanchangethisright/">bradleygee</a>.</div>
<hr/>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/vvDpM8VPH1I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2010/12/it-is-time-for-a-high-quality-perl-wiki/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2010/12/it-is-time-for-a-high-quality-perl-wiki/</feedburner:origLink></item>
		<item>
		<title>Cleanly Adapting WordPress Child Themes</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/Aq3hUhZXbEU/</link>
		<comments>http://www.perlsofwisdom.net/2010/12/cleanly-adapting-wordpress-child-themes/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 01:12:39 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[hybrid core]]></category>
		<category><![CDATA[theme hybrid]]></category>
		<category><![CDATA[wordpress themes]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=232</guid>
		<description><![CDATA[Soon, themes based on Hybrid Core will be parent themes and it will be easy to adapt them to your own requirements by creating a child theme. If you choose to use Prototype, a parent theme that already uses the latest version of Hybrid Core, you can do this already. However, there are some excellent [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/patchwork.jpg"><img src="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/patchwork.jpg" alt="" title="patchwork" width="320" height="223" class="aligncenter size-full wp-image-243" /></a></p>
<p>Soon, themes based on <a href="http://themehybrid.com/hybrid-core">Hybrid Core</a> will be parent themes and it will be easy to adapt them to your own requirements by creating a child theme.  If you choose to use <a href="http://themehybrid.com/archives/2010/10/prototype-wordpress-theme-version-0-1">Prototype</a>, a parent theme that already uses the latest version of Hybrid Core, you can do this already.</p>
<p>However, there are some excellent child themes based on the old <em>Theme Hybrid</em> way of doing things.  Justin agrees that these are not straightforward to update.</p>
<div class="quote">&quot;This is a new direction you’ll see from Theme Hybrid. Rather than releasing many complex child themes that are impossible to update, new themes will be parent themes. What this means is that you can make modifications to the themes with your own child theme. The goal has always been upgradibility, and that’s what I’d like to aim for with all themes.&quot;</div>
<h2>my_functions.php</h2>
<p>When I need to modify a complex (e.g. theme hybrid based) child theme I load a new file called <em>my_functions.php</em> at the end of <em>functions.php</em>.  I borrowed this idea from <a href="http://themeshaper.com/travailler-professional-wordpress-cms-theme/">Ian Stewart&#8217;s Travailler</a>, although I&#8217;m sure it&#8217;s been used many times before.</p>
<pre class="src">
<span style="color: #b22222;">/** </span><span style="color: #b22222;">my_functions.php *</span><span style="color: #b22222;">*/</span>

<span style="color: #a020f0;">function</span> <span style="color: #0000ff;">add_my_functions</span>() {

    $<span style="color: #b8860b;">my_functions_path</span> = <span style="color: #ff0000; font-weight: bold;">STYLESHEETPATH</span> . <span style="color: #bc8f8f;">'/my_functions.php'</span>;
    <span style="color: #a020f0;">if</span> (<span style="color: #000000; background-color: #ffffff;">file_exists(</span>$<span style="color: #b8860b;">my_functions_path</span>)) {
        <span style="color: #a020f0;">require_once</span>($<span style="color: #b8860b;">my_functions_path</span>);
    }
}

<span style="color: #000000; background-color: #ffffff;">add_action(</span><span style="color: #bc8f8f;">'wp_head'</span>, <span style="color: #bc8f8f;">'add_my_functions'</span>);
</pre>
<p>Then you can adapt the child theme from a clean starting point using <em>my-functions.php</em>.  For example:</p>
<pre class="src">
<span style="color: #da70d6;">&lt;?php</span>

<span style="color: #a020f0;">function</span> <span style="color: #0000ff;">my_byline</span>($<span style="color: #b8860b;">byline</span> = <span style="color: #bc8f8f;">''</span>) {
    <span style="color: #a020f0;">global</span> $<span style="color: #b8860b;">post</span>;

    $<span style="color: #b8860b;">byline</span> = <span style="color: #bc8f8f;">"[Empty Byline]"</span>;
    <span style="color: #a020f0;">return</span> $<span style="color: #b8860b;">byline</span>;
}

<span style="color: #000000; background-color: #ffffff;">add_filter(</span><span style="color: #bc8f8f;">'hybrid_byline'</span>, <span style="color: #bc8f8f;">'my_byline'</span>);

<span style="color: #da70d6;">?&gt;</span>
</pre>
<hr/>
<div class="attribution">Patchwork by <a href="http://www.flickr.com/photos/wheatfields/">net_efekt</a></div>
<hr/>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/Aq3hUhZXbEU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2010/12/cleanly-adapting-wordpress-child-themes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2010/12/cleanly-adapting-wordpress-child-themes/</feedburner:origLink></item>
		<item>
		<title>Why Dynamic Scope?</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/V0_5Y8kfzKQ/</link>
		<comments>http://www.perlsofwisdom.net/2010/12/why-dynamic-scope/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 23:47:16 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[dynamic scope]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=220</guid>
		<description><![CDATA[I never thought I&#8217;d see the day that dynamic scope was mentioned as a reason for using a language. I&#8217;m pretty sure I understand scope well and I consider myself a dynamic scope survivor due to my use of emacs lisp. I&#8217;ve never liked it though. So, for those of us who don&#8217;t remember Perl [...]]]></description>
			<content:encoded><![CDATA[<p>I never thought I&#8217;d see the day that dynamic scope was mentioned as <a href="http://blog.afoolishmanifesto.com/archives/1485">a reason for using a language</a>.</p>
<p>I&#8217;m pretty sure I understand scope well and I consider myself a dynamic scope survivor due to my <a href="http://www.perlsofwisdom.net/category/programming/emacs/">use of emacs lisp</a>.  I&#8217;ve never liked it though.  So, for those of us who don&#8217;t remember Perl 4, what is dynamic scope?</p>
<p>You know those <em>&quot;global&quot;</em> variables that perl provides, such as <em>$/</em> ?  When you do this:
</p>
<pre class="src">
{
    <span style="color: #a020f0;">local</span> <span style="color: #b8860b;">$/</span> = <span style="color: #66cd00;">undef</span>;
    <span style="color: #b22222;"># </span><span style="color: #b22222;">code
</span>}
</pre>
<p>you&#8217;re introducing a dynamic scope.  $/ is set to its previous value after the scope finishes.</p>
<h2>Emacs Lisp and Dynamic Scope</h2>
<p class="first">
Emacs lisp has loads of global variables all over the place that you can override.  One I use a lot is <em>inhibit-read-only</em>.  Dynamically scope that to non-nil and it is possible to write into read-only buffers.
</p>
<pre class="src">
(<span style="color: #a020f0;">let</span> ((inhibit-read-only t))
  (insert <span style="color: #bc8f8f;">"hello"</span>))
</pre>
<p>Back to Perl.</p>
<p>Under the covers, the <em>&lt;&gt;</em> operator is probably implemented a bit like this (only much more efficiently).</p>
<pre class="src">
open my $fh, '<span style="color: #228b22;">&amp;lt</span><span style="color: #b22222;">;</span><span style="color: #b22222;">', $ARGV[0];
</span>printf '^^^%s$$$' . <span style="color: #bc8f8f;">"\n"</span>, get_input($fh)<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>{
    local $GLOBAL::delimiter = undef<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>    printf '^^^%s$$$' . <span style="color: #bc8f8f;">"\n"</span>, get_input($fh)<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>}

sub get_input
{
    my $fh = shift<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>    my $buffer = ''<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>    my $c<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>    while (!defined($GLOBAL::delimiter) or $buffer !~ /$GLOBAL::delimiter$/) {
        my $read = read $fh, $c, 1<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>        if (!defined($read)) {
            die $!<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>        } elsif (!$read) {
            last<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>        }
        # printf <span style="color: #bc8f8f;">"C is[%s]\n"</span>, (ord($c) <span style="color: #228b22;">&amp;lt</span><span style="color: #b22222;">; </span><span style="color: #b22222;">32) ? ord($c) : $c;
</span>        $buffer .= $c<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>    }
    return $buffer<span style="color: #b22222;">;</span><span style="color: #b22222;">
</span>}
</pre>
<p>If you&#8217;re not a dynamic scope aficionado, you&#8217;re probably thinking, <em>why doesn&#8217;t get_input just have another parameter called delimiter which is defaulted to &quot;\n&quot; or whatever.</em></p>
<p>The dynamic scope guys will probably respond that <em>what about if you need to override the behaviour from the top of a deep deep call stack</em> ?</p>
<p>I have a bunch of superior ways of doing this using O-O and dynamic scope doesn&#8217;t play nicely with my [mostly] lexical variables in any case.</p>
<h2>And Finally&#8230;</h2>
<p>I was under the impression that dynamic scope was pretty much non-existent in modern languages.  Perl and Common Lisp have it, but lexical scope is, at least culturally, the default.  Python doesn&#8217;t really have proper scoping at all.  Dunno about Ruby, did those guys inherit it?</p>
<p>I was surprised to see Stevan mention in the comments that F# has it.</p>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/V0_5Y8kfzKQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2010/12/why-dynamic-scope/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2010/12/why-dynamic-scope/</feedburner:origLink></item>
		<item>
		<title>Watching Logfiles with Perl</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/r4yd2vyxsEc/</link>
		<comments>http://www.perlsofwisdom.net/2010/12/watching-logfiles-with-perl/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 23:52:07 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[perl tips]]></category>
		<category><![CDATA[poe]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=206</guid>
		<description><![CDATA[I often need to process a constantly updating resource. Sometimes the resource is a complex database backed application with a current state and a list of updates. Generally in these cases the procedure is as follows: subscribe to the updates and place them on a queue process the current state process the updates, beginning with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/watch-tower.jpg"><img src="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/watch-tower.jpg" alt="" title="watch-tower" width="320" height="214" class="aligncenter size-full wp-image-214" /></a></p>
<p>I often need to process a constantly updating resource.  Sometimes the resource is a complex database backed application with a current state and a list of updates.</p>
<p>Generally in these cases the procedure is as follows:</p>
<ul>
<li>subscribe to the updates and place them on a queue</li>
<li>process the current state</li>
<li>process the updates, beginning with the ones which were queued while processing the current state</li>
</ul>
<p>If you start by processing the current state and then subscribe to the updates, you&#8217;ll miss everything that happened while you were processing the current state.</p>
<h2>POE</h2>
<p class="first">For Perl users, <a href="http://search.cpan.org/dist/POE/">POE</a> handles this nicely.  The subscriber and the current state processor can be started in different sessions which trigger each-other at the important checkpoints.  For example, the current state processor shouldn&#8217;t start until the subscriber has successfully subscribed.</p>
<h2>POE::Wheel::FollowTail</h2>
<p>Other times, the resource is something much simpler &#8211; a logfile</p>
<p class="first">POE includes <a href="http://search.cpan.org/dist/POE/lib/POE/Wheel/FollowTail.pm">POE::Wheel::FollowTail</a> which is able to follow logfiles.  It isn&#8217;t necessary to subscribe to updates before processing the file as <em>POE::Wheel::FollowTail-&gt;new()</em> takes a Seek parameter which allows you to start from the beginning.</p>
<pre class="src">
<span style="color: #0000ff; background-color: #eeeed1; font-weight: bold;">$_</span>[HEAP]{<span style="color: #bc8f8f;">followtail</span>} = POE::Wheel::FollowTail-&gt;new(
    <span style="color: #bc8f8f;">Filename</span> =&gt; $logfile,
    <span style="color: #bc8f8f;">InputEvent</span> =&gt; <span style="color: #bc8f8f;">"got_log_line"</span>,
    <span style="color: #bc8f8f;">ResetEvent</span> =&gt; <span style="color: #bc8f8f;">"got_log_rollover"</span>,
    <span style="color: #bc8f8f;">Seek</span> =&gt; 0,
);
</pre>
<h2>When FollowTail Isn&#8217;t an Option</h2>
<p class="first">In some circumstances, it isn&#8217;t possible to use <em>FollowTail</em>.  For example, the server where the logfile is, may only allow simple commands to be run, not scripts.  In this case, the solution could be <a href="http://search.cpan.org/dist/POE/lib/POE/Wheel/Run.pm">POE::Wheel::Run</a>.</p>
<p><a href="http://linux.die.net/man/1/tail">tail(1)</a> usually takes a parameter that will allow you to start processing the logfile from the start.</p>
<pre class="src">
ssh servername 'tail -n+0 -f /full/path/here/logfile.txt'
</pre>
<hr/>
<div class="attribution">WatchTower by <a href="http://www.flickr.com/photos/bazylek/">bazylek100</a></div>
<hr/>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/r4yd2vyxsEc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2010/12/watching-logfiles-with-perl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2010/12/watching-logfiles-with-perl/</feedburner:origLink></item>
		<item>
		<title>Carp Stacktraces</title>
		<link>http://feedproxy.google.com/~r/PerlsOfWisdom/~3/BqWFyjz0IAk/</link>
		<comments>http://www.perlsofwisdom.net/2010/12/carp-stacktraces/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 01:08:52 +0000</pubDate>
		<dc:creator>Ted James</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[perl tips]]></category>

		<guid isPermaLink="false">http://www.perlsofwisdom.net/?p=199</guid>
		<description><![CDATA[Most well-written perl modules use croak or carp instead of die or warn so that you can see which line in the calling code resulted in the error message. When debugging it can be helpful to see a full stacktrace instead. The easiest option is to add a perl argument -MCarp=verbose. perl -MCarp=verbose script.pl Alternatively [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/koi-carp.jpg"><img src="http://www.perlsofwisdom.net/wp-content/uploads/2010/12/koi-carp.jpg" alt="" title="Koi Carp" width="320" height="229" class="aligncenter size-full wp-image-203" /></a></p>
<p>Most well-written perl modules use <em>croak</em> or <em>carp</em> instead of <em>die</em> or <em>warn</em> so that you can see which line in the calling code resulted in the error message.  When debugging it can be helpful to see a full stacktrace instead.</p>
<p>The easiest option is to add a perl argument <em>-MCarp=verbose</em>.</p>
<pre class="src">
perl -MCarp=verbose script.pl
</pre>
<p>Alternatively you can either:</p>
<ul>
<li>Add <em>$Carp::Verbose = 1</em> in your script <strong>or</strong></li>
<li>Add <em>-MCarp=verbose</em> to the PERL5OPT environment variable</li>
</ul>
<p><a href="http://perldoc.perl.org/Carp.html">Carp.pm documentation</a></p>
<hr/>
<div class="attribution">Carp by <a href="http://www.flickr.com/photos/ell-r-brown/">Ell Brown</a></div>
<hr/>
<img src="http://feeds.feedburner.com/~r/PerlsOfWisdom/~4/BqWFyjz0IAk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.perlsofwisdom.net/2010/12/carp-stacktraces/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.perlsofwisdom.net/2010/12/carp-stacktraces/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.perlsofwisdom.net @ 2012-05-09 12:47:58 -->

