<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Cat Eats Mouse</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/mithaldu/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/mithaldu//415</id>
    <updated>2012-09-22T13:50:21Z</updated>
    <subtitle>and Perl happens</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>How many ways to start a process do you know?</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2012/09/how-many-ways-to-start-a-process-do-you-know.html" />
    <id>tag:blogs.perl.org,2012:/users/mithaldu//415.3865</id>

    <published>2012-09-22T13:47:48Z</published>
    <updated>2012-09-22T13:50:21Z</updated>

    <summary>Note: The titular question applies only to different ways in Perl. I am planning to write a small guide/comparison of the different ways to start a process in Perl and while thinking about all the ways i do know, became...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p>Note: The titular question applies only to different ways in Perl.</p>

<p>I am planning to write a small guide/comparison of the different ways to start a process in Perl and while thinking about all the ways i do know, became certain that:</p>

<p>1. my knowledge about the ways i know is not complete<br />
2. there will be ways i do not even know about</p>

<p>Thus i am turning to the Perl community for help. Please tell me what ways you know to start a process in Perl and all of the permutations it can go through. :)</p>]]>
        
    </content>
</entry>

<entry>
    <title>How the YAPC::NA videos got on Youtube</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2012/06/how-the-yapcna-videos-got-on-youtube.html" />
    <id>tag:blogs.perl.org,2012:/users/mithaldu//415.3404</id>

    <published>2012-06-17T09:11:44Z</published>
    <updated>2012-06-17T10:07:46Z</updated>

    <summary>p { text-align:justify }.prettyprint { color: darkred } In my previous post oalders (of Metacpan) asked me about how working on Windows influenced the process and in answering him i got a bit more wordy, so here&apos;s another post: Video...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p><style>p { text-align:justify }.prettyprint { color: darkred }</style></p>

<p>In my previous post <a href="https://metacpan.org/author/OALDERS">oalders</a> (of Metacpan) asked me about how working on Windows influenced the process and in answering him i got a bit more wordy, so here's another post:</p>

<p>Video is a bit easier on Windows because, even if many of those are very amateur, it has a wider spread of tools available. However, that said, i still needed a bunch of linux tools (that i could luckily run on windows).</p>

<p>First issue was to free the stream from the Silverlight player. As mentioned in the previous blog post, lots of people helped with that.</p>

<p>Next was getting it dumped to the hard disk into a file i could actually play back afterwards. Windows Media Player couldn't, Mplayer crashed and only VLC finally worked. The command lines i saw didn't help a lot, but it led the way because it did produce some kind of file. By fiddling with the GUI i could get it to dump a usable file. And after converting the gui settings back into command line instructions (after cursing VLC's terrible documentation) i was able to perform the dumping with scripts. The command line instructions ended up being:<br />
<blockquote>qw[ --sout-keep --sout "#transcode{vcodec=div3,acodec=mp3,vb=6000,ab=320,deinterlace}:duplicate{dst=display,dst=std{mux=asf,access=file,dst=$dump_file.asf}" ]</blockquote></p>

<p><br />
The "keep" option is important. When the stream was cut off at the venue, i.e. by shutting off a camera, VLC would try to reconnect to the stream and in the process overwrite the data it had dumped with an empty ASF header file. The keep "keep" option prevented that from happening (but not before a lot of data was lost). Another issue here was: While streaming and dumping the volume controls of VLC did literally nothing. Windows 7 helped here by providing me with volume sliders per process.</p>

<p>Next was converting the raw ASF stream into something that could be distributed. No tool i had could actually read it. At first i tried <a href="http://www.asftools.de/">ASFTools</a>, but that only resulted in a very desynched stream. This is caused by the fact that ASF has non-constant FPS. This doesn't mean it changes sometimes, but literally all the time. Hobbs helped me later with the conversion and said the file was apparently at 1000 FPS. So ASFTools was useless for the conversion, but it helped me with one thing: The asf files were unseekable, so short of watching the entire thing i could not tell what was actually dumped. ASFTools was able to fix that without recompression.</p>

<p>Hobbs contribution here was also immeasurable. I was entirely stumped with the conversion. None of my tools could make sense of the ASF files, even though they could play them. He worked out and provided me with parameters for mencoder to reencode them into AVI format, which ended up, after some fine-tuning, to be this:<br />
<blockquote>mencoder -quiet -oac mp3lame -lameopts q=1 -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3 -ffourcc DIVX -ofps 30 -o %1.avi %1</blockquote></p>

<p><br />
After that the lion's share of mental work was done and what remained was mostly menial work: Cutting the files into pieces and uploading them. Here's another part where Windows was really useful. VirtualDub is a free, open-source and lightweight tool for video processing. It also makes it extremely easy to cut videos without reencoding them by making it easy to navigate between keyframes, select regions and dump them straight to fily with Direct Stream mode. This took considerable time because i needed to go through all the dumps, find appropiate start and end points for the talks and figure out exactly what talk it was and what its title should be.</p>

<p>Last came the uploading to Youtube. I had luckily recently upgrade my internet connection, so i could upload at ~300kbyte/sec. However this also meant that i had uploaded four 50-minute videos before Youtube told me that it rejected the files for being too long. However, this restriction only required a validation of my cell phone number, which only took a minute all in all. I did need to reupload those videos again though. After that i dumped them all into a playlist (which i had to nuke at some point, because Youtube will happily add videos to playlists multiple times) and sorted them in some kind of chronological order.</p>

<p>And now you can watch them. :)</p>

<p>One last note: After i had uploaded many of the videos to youtube already, JT sent me an email to ask me to discuss a small matter relating to the videos and also mentioned that while i had not obtained permission, he would allow me to leave them up. I was a bit unhappy about it, but in retrospect he was correct. I did not think of it at the time because i was too busy figuring out the technical details, but i should have asked. However, please don't take this as discouragement in case you ever think of doing this for another con. Con organizers will love you to death if you offer to do this for them. Just make sure you let them know in advance and ask permission, because sometimes they have to deal with legal issues involving third parties.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Early set of YAPC::NA 2012 videos on Youtube</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2012/06/early-set-of-yapcna-2012-videos-on-youtube.html" />
    <id>tag:blogs.perl.org,2012:/users/mithaldu//415.3400</id>

    <published>2012-06-16T12:52:14Z</published>
    <updated>2012-06-17T10:08:09Z</updated>

    <summary>p { text-align:justify }.prettyprint { color: darkred } I wasn&apos;t able to attend YAPC::NA 2012. Yet i was able to attent YAPC::NA 2012. &quot;Huh?&quot; you say. Simple, i was what is called a Remote Attendee. With #yapc on irc.perl.org, the...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p><style>p { text-align:justify }.prettyprint { color: darkred }</style></p>

<p>I wasn't able to attend YAPC::NA 2012.</p>

<p>Yet i was able to attent YAPC::NA 2012.</p>

<p>"Huh?" you say.</p>

<p>Simple, i was what is called a <a href="http://act.yapcna.org/2012/wiki?node=Remote%20attendees">Remote Attendee</a>. With #yapc on irc.perl.org, the con had an excellent and well-frequented IRC channel where both people that stayed at home, as well as physical con attendants mingled and talked about god, the world, con organization, the talks being given and software in general. Everyone was able to chat about the talks because the con orga had managed to make live streams available for four of the five con rooms and that in excellent quality.</p>

<p>So thanks a lot for JT and the rest of the YAPC::NA staff for a job extremely well done!</p>

<p>The only dark-grey mark: The venue insisted on using their own system, which streamed ASF via a Silverlight player. People could use Moonlight, but a good number of people refused that on principle. <a href="https://gist.github.com/2926115">Enterprising</a> <a href="https://gist.github.com/2926763">perl</a> <a href="https://gist.github.com/2926769">mongers</a> quickly figured out how to play the streams with VLC and also how to dump them to disk. On Friday, the third day, i started using these to capture on my windows machine and despite some setbacks via VLC, i was able to grab a bulk of the talks on that day.</p>

<p>All of these videos are now up in this <a href="http://www.youtube.com/playlist?list=PLE3F888A650339DDF&feature=plcp">Youtube Playlist</a>. So if you didn't get to see any of the talks, or missed one you wanted to see, have a look, maybe it's in there. And if you haven't seen <a href="http://www.youtube.com/watch?v=NUAOns_WAXA&list=PLE3F888A650339DDF&index=1&feature=plpp_video">Perl and CPAN</a> or the <a href="http://www.youtube.com/watch?v=oX4mHT7BXUs&list=PLE3F888A650339DDF&index=15&feature=plpp_video">Surprise Guest Speaker</a> talk you should go see them now.</p>

<p>As well, you might want to check back later, as i'm still working grabbing and converting more backlog. It won't be complete coverage of the con, which will be done later by <a href="http://www.presentingperl.org/">Presenting Perl</a>, but it should tide you over until then.</p>

<p>On request i can also make the raw video files available that i got. You can grab me via my CPAN email or as Mithaldu on irc.perl.org.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Why does your site not link to perl.org?!</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2012/01/why-does-your-site-not-link-to-perlorg.html" />
    <id>tag:blogs.perl.org,2012:/users/mithaldu//415.2705</id>

    <published>2012-01-19T19:14:04Z</published>
    <updated>2012-01-19T23:02:39Z</updated>

    <summary> Recently an article was published that claimed Perl usage in websites had dropped below 1%. For a Perl developer this seems ridiculous on the face of it. As it turned out, it was ridiculous, since the error margin was...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<span style="text-align:justify">
<p>Recently an article was published that claimed <a href="http://w3techs.com/blog/entry/usage_of_perl_for_websites_fell_below_1_percent">Perl usage in websites had dropped below 1%</a>. For a Perl developer this seems ridiculous on the face of it. As it turned out, it was ridiculous, since the error margin was 17.6%. Meaning that for 17.6% of the sites they surveyed they could not even detect that they were using Perl. And they only survey the top 1 million, out of the 175 million active sites Netcraft reported. So the validity of these numbers is highly suspect.</p>

<p>So, all is fine? Catastrophe averted? Heh, not really.</p>

<p>Here's the issue: To a Perl developer this might seem ridiculous. Most of us are aware of how many websites use it under the hood. But to the average person it seems perfectly reasonable. The suffixes ".php" and ".asp" are ubiquitous and lets everyone know what the website is running on. Ruby and Python operations are <em>proud</em> of using their languages and flaunt it. To an average person it might even seem like there are more Ruby and Python websites.</p>

<p>Yet Perl is practically invisible. It drives a lot of sites, businesses and livelihoods worldwide, neither of which make <em>any</em> indication of the tools they're using. Let's take a look at a random sampling:</p>

<center>
<table>
    <tr><th>Site</th>               <th>Alexa Rank</th></tr>
    <tr><td><a href="http://imdb.com">imdb.com</a></td>             <td>37</td></tr>
    <tr><td><a href="http://booking.com">booking.com</a></td>           <td>245</td></tr>
    <tr><td><a href="http://cpanel.net">cpanel.net</a></td>             <td>1,710</td></tr>
    <tr><td><a href="http://blogs.suntimes.com/">blogs.suntimes.com</a></td>     <td>2,171</td></tr>
    <tr><td><a href="http://net-a-porter.com">net-a-porter.com</a></td>     <td>2,195</td></tr>
    <tr><td><a href="http://lovefilm.com">lovefilm.com</a></td>         <td>3,149</td></tr>
    <tr><td><a href="http://liquidweb.com">liquidweb.com</a></td>           <td>7,776</td></tr>
    <tr><td><a href="http://slando.com">slando.com</a></td>             <td>25,266</td></tr>
    <tr><td><a href="http://socialtext.net">socialtext.net</a></td>         <td>145,896</td></tr>
    <tr><td><a href="http://bestpractical.com">bestpractical.com</a></td>       <td>161,366</td></tr>
    <tr><td><a href="http://metacpan.org">metacpan.org</a></td>         <td>172,291</td></tr>
    <tr><td><a href="http://hiveminder.com">hiveminder.com</a></td>         <td>295,127
</td></tr>
</table>
</center>
<br />

<p>These are sites that run on Perl, but to look at them you'd never even know it. Perl has advanced route dispatching mechanisms and its great modularity makes it possible to write an entire website as a single application. In fact, for most modern Perl web frameworks it has become customary to run web applications as self-hosting services to which a web server connects via a network port. Perl has made it very easy to design one's url structure exclusively around the data one serves, which has made it entirely impossible to tell for most Perl-driven sites that they actually are Perl.</p>

<p>Now, all of these sites have reasons to be proud of the tools they use. Some of them indeed are very proud, booking.com for example has donated 150.000 USD last year to Perl development and others on the list have donated smaller amounts as well or are supporting Perl conferences and spend a lot of money to have a presence on Perl conferences. Those on the list who are hiring, are also hiring Perl developers, some of them quite prominently. Even others on the list are websites created for the express purpose of serving the Perl community.</p>

<p>Yet none of them even mention Perl on their frontpage or even link to <a href="http://perl.org">perl.org</a>. I know Perl doesn't have nice and easy promotion buttons like <a href="http://www.python.org/community/logos/">Python</a> or <a href="http://php.net/download-logos.php">PHP</a> do. But a simple text link does the job just as well. Just a simple "Built with <a href="http://perl.org">Perl</a>" in the footer or a sidebar would show that you care about Perl, would make it easier for job seekers to notice that you're looking for Perl devs and would raise the visibility of Perl and make it a more appealing choice for students looking to learn a dynamic language.</p>

<p>I do not believe this is done out of any maliciousness and that it's rather just a simple oversight, something that was never considered. As such i've sent a small email to each of those sites, asking them to consider this issue and to please add a link to perl.org or to weigh in on why they would not do it. Maybe they are issues that the Perl community can fix.</p>

<p>Similarly, if you own a site yourself that runs on Perl and does not link to perl.org:</p>

<center><p><strong>Why does your site not link to perl.org?!</strong></p></center>
</span>]]>
        
    </content>
</entry>

<entry>
    <title>Augmenting the Perl debugger for fun and profit</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/12/augmenting-the-perl-debugger-for-fun-and-profit.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.2531</id>

    <published>2011-12-03T10:23:20Z</published>
    <updated>2011-12-03T12:11:23Z</updated>

    <summary> Background Problem Implementation Solution p { text-align:justify }.prettyprint { color: darkred } Background I like the Perl debugger a lot. I use it daily, since understanding code by seeing it execute is much better than guessing at what it...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<ul>
<li><a href="#Background">Background</a></li>
<li><a href="#Problem">Problem</a></li>
<li><a href="#Implementation">Implementation</a></li>
<li><a href="#Solution">Solution</a></li>
</ul>

<p><style>p { text-align:justify }.prettyprint { color: darkred }</style></p>

<h2 id="Background">Background</h2>

<p>I like the <a href="https://metacpan.org/module/perldebug">Perl debugger</a> a lot. I use it daily, since understanding code by seeing it execute is much better than guessing at what it does based on its API. I do however seldomly use the actual command line debugger module, but instead use the Perl debugger built into <a href="http://www.activestate.com/komodo-ide/features#debugging">Komodo IDE</a> because it streamlines a lot of the busywork that is necessitated by having a debugger bound to a terminal:</p>

<ul>
<li>It automatically shows the variables in the surrounding lexical scope instead of making me type <code>x $var&lt;ret&gt;</code> every time i want to see my variables.</li>
<li>It allows me to step in, over or out of statements/subs by clicking, which is a lot faster than typing <code>s&lt;ret&gt;</code>, <code>n&lt;ret&gt;</code> or <code>r&lt;ret&gt;</code> a lot.</li>
<li>It allows me to have the debugger run to a certain line in the current or also other files by just setting the cursor on the line and hitting the shortcut for "Run to cursor".</li>
<li>It allows me to define and store breakpoints based on the results of perl expressions without actually altering my source code.</li>
<li>And more.</li>
</ul>

<h2 id="Problem">Problem</h2>

<p>All is not perfect however. Both Komodo IDE and perl5db.pl lack nice interfaces for doing the opposite of a breakpoint, which is ignoring statements. Komodo IDE has flat-out no interface for that. The core perl5db.pl allows the user to define a sub <a href="https://metacpan.org/module/perl5db.pl#watchfunction-">DB::watchfunction()</a> which is executed in the debugger's scope and can skip out, but that's a lot of busywork and means I'd have to specifically write the sub for all of my code.</p>

<p>Why is this important? Consider Web::Simple's role <a href="https://metacpan.org/source/MSTROUT/Web-Simple-0.010/lib/Web/Dispatch/ToApp.pm#">Web::Dispatch::ToApp</a>. This is executed a lot during the dispatch process, which is also where i do a lot of my debugging to make sure my routes are solid. That means whenever a piece of code goes <code>$obj-&gt;to_app-&gt;()</code>, i have to step into <code>to_app</code> in order to be able to step into the actual <code>call</code> sub of <code>$obj</code>. Another example would be Moo's <a href="https://metacpan.org/source/MSTROUT/Moo-0.009012/lib/Sub/Defer.pm#L37">Sub::Defer::defer_sub::ANON</a>, which is invoked on almost all Moo attribute accessors. That kind of thing is annoying and a waste of time.</p>

<p>So, what i needed was a module that can be loaded in my code, will be given some import parameters and will cause both the Komodo IDE debugger as well as perl5db.pl to skip over statements based on package or fully qualified sub-routine name.</p>

<p>If you don't care about the implementation, you can skip to the end of the article now, where i show the solution.</p>

<h2 id="Implementation">Implementation</h2>

<p>Thanks to an <a href="http://www.effectiveperlprogramming.com/blog/1429">article by brian d foy</a> (hope i got his name right) I found that the Perl debugger modules are actually fairly simple: "Under the -d switch, perl calls &amp;DB::DB before each statement" This is also documented in more detail in <a href="http://perldoc.perl.org/perldebguts.html#Debugger-Internals">perldebguts</a>.</p>

<p>Armed with that knowledge it's simple to write a function that augments the current <code>DB::DB()</code> with a bit of code that interrogates the caller before heading into the debugger proper. We can't just directly call the old <code>DB::DB()</code> function, since it relies on the stack level and makes heavy use of <code>caller()</code>. So, a simple replacement that stores the old function and uses <code>goto &amp;{$ref}</code> should do the trick:</p>

<pre><code>    my $old_db = \&amp;DB::DB;
    *DB::DB = sub {
        goto &amp;{ $old_db };
    };
</code></pre>

<p>Sadly it turns out that the goto makes the whole thing go out of the protected debugger scope in which <code>DB::DB</code> is <em>not</em> executed for every statement; resulting in something akin to a fork bomb. So before we can actually do interesting stuff, we have to add a bit of code to skip out when we're being called from inside <code>DB</code> or any other <code>DB::*</code> module:</p>

<pre><code>    my $old_db = \&amp;DB::DB;
    *DB::DB = sub {
        my $lvl = 0;
        while ( my ( $pkg ) = caller( $lvl++ ) ) {
            return if $pkg eq "DB" or $pkg =~ /^DB::/;
        }

        goto &amp;{ $old_db };
    };
</code></pre>

<p>I think it should be possible to munge with the stack directly as well, so we can just use <code>return $old_db-&gt;( @_ )</code>, but my Perl-fu is not that good and Sub::UpLevel looks fairly daunting. (Suggestions welcome though.) One would think that doing it this way would make the debugger a lot slower, but honestly, i've been using it for a while now and couldn't notice a difference.</p>

<p>So, now we have a piece of code that acts as a pass-through to the debugger and doesn't blow everything up. That means we can add code to actually <em>do</em> things, but this turns out to be fairly trivial.</p>

<pre><code>    my %pkg_skip = (...);
    my %sub_skip = (...);

    my $old_db = \&amp;DB::DB;
    *DB::DB = sub {
        my $lvl = 0;
        while ( my ( $pkg ) = caller( $lvl++ ) ) {
            return if $pkg eq "DB" or $pkg =~ /^DB::/;
        }

        return if $pkg_skip{ (caller)[0] };

        my $sub = ( caller(1) )[3];
        return if $sub and $sub_skip{$sub};

        goto &amp;{ $old_db };
    };
</code></pre>

<p>There we go, a working piece of code that makes the debugger skip over statements in certain scopes or subs.</p>

<h2 id="Solution">Solution</h2>

<p>With a bit of parametrizing and cleaning up of this, the result is <a href="https://metacpan.org/module/DB::Skip">DB::Skip</a>, a module that you can load in your code when you want to augment the debugger to skip statements. The use is extremely simple and it's made debugging a lot more pleasant for me already:</p>

<pre><code>    use DB::Skip (
        pkgs =&gt; [
            qr/^Method::Generate::/,
            qw(  Sub::Defer  Sub::Quote  Web::Dispatch::ToApp  )
        ],
        subs =&gt; [ 'Web::Dispatch::MAGIC_MIDDLEWARE_KEY' ]
    );
</code></pre>
]]>
        

    </content>
</entry>

<entry>
    <title>Perl tutorials suck (and cause serious damage)</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/10/perl-tutorials-suck-and-cause-serious-damage.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.2361</id>

    <published>2011-10-26T10:30:54Z</published>
    <updated>2012-04-04T11:31:24Z</updated>

    <summary>Before reading this entry, please note that this problem has been solved. You can now find fresh tutorials at the: Perl Tutorial Hub And now back to your scheduled rant: PREFACE THE PROBLEM Solutions Content Creation Outreach SEO QUESTIONS PREFACE...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p style="text-align:justify;">Before reading this entry, please note that this problem has been solved. You can now find fresh tutorials at the:</p>
<h1 style="text-align:center;"><a href="http://perl-tutorial.org/">Perl Tutorial Hub</a></h1>
<p style="text-align:justify;"><br /><br />And now back to your scheduled rant:</p>

<hr />

<p><a name="___pod"></a><ul id="index" style="list-style-type:none;">  <li style="list-style-type:none;"><a href="#Preface">PREFACE</a></li>  <li style="list-style-type:none;"><a href="#Problem">THE PROBLEM</a></li>  <li style="list-style-type:none;"><a href="#Solutions">Solutions</a></li>    <ul style="list-style-type:none;margin:0">      <li style="list-style-type:none;"><a href="#Content">Content Creation</a></li>      <li style="list-style-type:none;"><a href="#Outreach">Outreach</a></li>      <li style="list-style-type:none;"><a href="#SEO">SEO</a></li>    </ul>  <li style="list-style-type:none;"><a href="#Questions">QUESTIONS</a></li></ul></p>

<h1><a name="Preface" href="#___pod">PREFACE</a></h1>

<p style="text-align:justify;">On monday a blog post made the rounds that claimed <a href="http://www.neverworkintheory.org/?p=197">"Perl users were unable to write programs more accurately than those using a language designed by chance."</a> Naturally that is not the entire truth. As it turns out they "trained" their test subjects using examples of code that they considered representative of what a user would find when trying to learn Perl from the internet. That code looked like this:

<pre>
$x = &z(1, 100, 3);

<p>sub z{<br />
    $a = $ [0];<br />
    $b = $ [1];<br />
    ...<br />
    for ($i = $a; $i <= $b; $i++){<br />
    ...<br />
    if ($d > $e) {<br />
        $d;<br />
    }<br />
    $e;<br />
}<br />
</pre></p>

<p style="text-align:justify;">Naturally the outcry (including from me) went: "But that is Perl 4 code, of course the test subjects had a friggin hard time with it!" But were they wrong in choosing that example to teach with? Was that representative of what a complete perl beginner would find online?

<h1><a name="Problem" href="#___pod">THE PROBLEM</a></h1>

<p style="text-align:justify;">Turns out, that yes, it was representative. <b>The code above represents exactly the very first thing found when looking for Perl learning material.</b>

<p style="text-align:justify;">How so? In <a href="http://blogs.perl.org/users/mithaldu/2011/10/how-do-newbies-find-perl-learning-materials-online.html">a post yesterday</a> i asked for help in finding out what a perl newbie would try <b>first</b> when wanting to learn Perl. Google Trends is a great tool, as it shows comparatively how often certain search terms are used. And it turns out that among the highest performing search terms there is one that is at least twice as often used as any other search term:

<div style="text-align: center;"><a  style="text-align: center;font-weight:bold;font-size:1.5em;" href="http://www.google.de/search?q=perl+tutorial">perl tutorial</a></div>

<p><br />
<p style="text-align:justify;">And quite frankly, the results for that search suck. Incredibly so.</p>

<p style="text-align:justify;">The first result, a site by the University of Leeds, in the UK, carries this warning at the top: "<i>This tutorial was written in the early 1990's for version 4 of Perl. Although it is now significantly out of date, it was a popular source of information for many people over many years. It has therefore been left on-line as part of the historical archive of the Internet.</i>" 21 years later, in 2011, it is still the very first thing Google brings up when looking for perl tutorials and that is exactly what newbies world-wide do first.

<p style="text-align:justify;">Make no mistake though, it is not just the first result that is terrible. Result two ( perltutorials.org ), features Perl 4 code as well and result three ( tizag.com ) attempts to teach "PERL", also using Perl 4 reminiscent code. Search result four is a highlight, in that it is Gabor Szabo's excellent fledgling <a href="http://szabgab.com/perl_tutorial.html">Perl tutorial series with videos</a>. But the very next result goes back to 2000, with an article on perl.com, which already features 5.10 and nicer forms of `for`, but still eschews talking about strict, warnings, or even using `my`. After that comes <a href="http://learn.perl.org/">Learning Perl</a>, which is a bit barebones, but features a nice modern Hello World. Yet right next up is a link to a free online copy of the book Beginning Perl, which might sound nice, but is anything but, thanks to being the edition from 2000, which teaches Perl 5.6.

<p style="text-align:justify;">I could go on, but it doesn't get any better. Only worse.

<p style="text-align:justify;">If you've wondered why the public perception of Perl is that of an old language, this is the reason. Our public face to anyone new to Perl and wanting to learn is dominated by material from the turn of the century, or earlier.

<h1><a name="Solutions" href="#___pod">SOLUTIONS</a></h1>

<p style="text-align:justify;">Now, i honestly do not know how to best solve this, but i can bring up some ideas.

<h2><a name="Content" href="#___pod">Content Creation</a></h2>

<p style="text-align:justify;">Now, as far as i am aware there is no current, definitive and in-depth Perl tutorial anywhere. Please correct me if there is one.

<p style="text-align:justify;">Gabor Szabo has made a good start, but it's only a start. Right now his series is tiny and he is only one person. Another good attempt it learn.perl.org, bug again, too small in scope. It provides a few bites, a few examples, basically just a taste of Perl and then tells the peruser to look at other sites. These approaches suffer from a few flaws in that they fail to properly capture and provide for the newbie.

<p style="text-align:justify;">So, we need a good modern Perl tutorial. Not just books. We need something in the style of the Leeds University document, but with all the anachronisms filtered out and current knowledge inserted. Something like the <a href="http://docs.python.org/tutorial/">Python Tutorial</a>. And most importantly, it needs to be a community effort. It cannot hinge on just one person.

<p style="text-align:justify;">Possible options i see are to either create a wiki on a domain like tutorial.perl.org/com and take pains to ensure that editing and updating it is easy and effortless. Alternatively it could be done by ways of a github repo, possibly even within the perl core repo, which is then exported to HTML regularly.

<p style="text-align:justify;">Using a structure like this, the community at large could concentrate on writing the textual content, while people like Gabor can still contribute videos. It could be a very nice mix of the python tutorial and <a href="http://railscasts.com/">RailsCasts</a>.

<p style="text-align:justify;">Make it good enough, publicize it and Google search results would right themselves on their own.

<h2><a name="Outreach" href="#___pod">Outreach</a></h2>

<p style="text-align:justify;">Another option would be to reach out to the maintainers of those sites and convince them to take down their sites or at the very least add links that prominently point to more modern content. Alternatively they could be asked to cooperate with the Perl community in making it possible to change and update the contents of those sites.

<p style="text-align:justify;">Then there's also the matter of the people linking to those sites, outreach could also be done to them by ways of finding out with www.backlinkwatch.com who links to them, and then convince those sites to remove/change their links to newer materials.

<h2><a name="SEO" href="#___pod">SEO</a></h2>

<p style="text-align:justify;">Failing the above two, there are still measures that could be taken to aggressively alter Google's view on what's relevant to perl tutorials. This could be in the form of burying results we do not care about, or promoting results we do care about. It is in my eyes a last resort and might involve money expenditure, but given the circumstances i do not see it as entirely unwarranted.

<p>Edit: A <a href="http://www.reddit.com/r/programming/comments/lpmaq/perl_tutorials_suck_and_cause_serious_damage/c2ul9p7">suggestion from Reddit</a>: "the new +1 feature for search results may come in handy. Get the entire community to +1 the same link."</p>

<h1><a name="Questions" href="#___pod">QUESTIONS</a></h1>

<p style="text-align:justify;">Some questions still going through my head:

<ul style="text-align:justify;">
	<li>Are there perl tutorial sites i do not know about that have good and copious content?</li>
	<li>If so, how could we effectively advertise them, so Google picks up on them?</li>
	<li>Are there other options i did not think about?</li>
</ul>

<p><br />
<p style="text-align:justify;">And with that, i close this entry and leave it to you to ponder and provide feedback and most importantly: Help repair the image of Perl.</p>

<p></span></p>]]>
        
    </content>
</entry>

<entry>
    <title>How do newbies find Perl learning materials online?</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/10/how-do-newbies-find-perl-learning-materials-online.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.2350</id>

    <published>2011-10-25T11:51:34Z</published>
    <updated>2011-10-25T13:28:03Z</updated>

    <summary>This is a very short entry, which will lead to a long one later. Right now in light of the recent hubbub about the study claiming that perl&apos;s as good as a randomized language for newbies, i am trying to...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p>This is a very short entry, which will lead to a long one later. Right now in light of the recent hubbub about the study claiming that perl's as good as a randomized language for newbies, i am trying to find out just how a newbie searches for Perl learning materials online and what he finds first.</p>

<p>Right now i'm concentrating on what kind of search term a newbie would enter in Google. Luckily Google trends help a bit there, allowing me to compare between various search terms.</p>

<p><a href="http://www.google.de/trends?q=perl+tutorial%2C+perl+cgi%2C+programming+perl%2C+perl+examples%2C+perl+learn&ctab=0&geo=all&date=ytd&sort=0">These are the search terms i came up with or was suggested</a>:</p>

<p><font size=-1 font color=4684ee><b>perl tutorial</b>&nbsp;</font><font size=-2>1.00&nbsp;&nbsp;&nbsp;&nbsp;</font><font size=-1 font color=dc3912><b>perl cgi</b>&nbsp;</font><font size=-2>0.79&nbsp;&nbsp;&nbsp;&nbsp;</font><font size=-1 font color=ff9900><b>programming perl</b>&nbsp;</font><font size=-2>0.45&nbsp;&nbsp;&nbsp;&nbsp;</font><font size=-1 font color=008000><b>perl examples</b>&nbsp;</font><font size=-2>0.37&nbsp;&nbsp;&nbsp;&nbsp;</font><font size=-1 font color=4942cc><b>perl learn</b>&nbsp;</font><font size=-2>0.10</font></p>

<p><img alt="perl_compare_2.png" src="http://blogs.perl.org/users/mithaldu/2011/10/25/comparison/perl_compare_2.png" width="580" height="260" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></p>

<p>Please help me and see if you can think of any other search terms that would be more often used than "perl tutorial". Thanks in advance.</p>]]>
        
    </content>
</entry>

<entry>
    <title>DBD::mysql 4.019 and 4.020 are broken on Win32, here&apos;s how to downgrade</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/10/dbdmysql-4019-and-4020-are-broken-on-win32-heres-how-to-downgrade.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.2318</id>

    <published>2011-10-20T13:06:28Z</published>
    <updated>2011-10-21T06:22:31Z</updated>

    <summary>Edit: ActivePerl&apos;s Jan Dubois has kindly applied a patch to DBD-mysql 4.020 on their servers, so you can just do this: Original post: This a warning to Win32 perl devs using DBD-mysql. The versions 4.019 and 4.020 are broken in...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p><strong>Edit:</strong></p>

<p>ActivePerl's Jan Dubois has kindly applied a patch to DBD-mysql 4.020 on their servers, so you can just do this:<br />
<script src="https://gist.github.com/1303226.js"> </script></p>

<hr />

<p><strong>Original post:</strong></p>

<p>This a warning to Win32 perl devs using DBD-mysql.</p>

<p>The versions 4.019 and 4.020 are broken in a rather subtle way: All SQL errors are silently ignored and in fact not even triggered, no matter what RaiseError is set to or what kind of error happens. As an example, this code will run without a complaint:</p>

<p><script src="https://gist.github.com/1301108.js"> </script></p>

<p>Various messages have been sent to the maintainers of DBD-mysql, including a <a href="http://lists.mysql.com/perl/4415">proposal for a fix</a>. However, implementation of a fix and release of a new version will likely take some time.</p>

<p>In the meantime downgrading is the only viable option, but sadly the ppm client does not make that kind of thing very easy. As such, this is the command you will need to execute to downgrade your DBD-mysql:</p>

<p><script src="https://gist.github.com/1301114.js"> </script></p>

<p>Note that is compiled for Perl 5.12. By changing the Perl version part of the url you can also get it for 5.8 and 5.10. For 5.14 there is no ppm available though, so if you're using that you will have to downgrade your entire Perl or try your luck with the 5.12 one.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Fixing XSS in Catalyst with a really big hammer</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/07/fixing-xss-in-catalyst-with-a-really-big-hammer.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.1981</id>

    <published>2011-07-17T13:21:36Z</published>
    <updated>2011-07-20T06:45:43Z</updated>

    <summary>A few friends of mine are currently working on a community website of sorts, which means they&apos;ll have tons of user-provided content and interaction. This also means there are possible XSS problems all over the place. So they stated dutifully...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p>A few friends of mine are currently working on a community website of sorts, which means they'll have tons of user-provided content and interaction. This also means there are possible XSS problems all over the place.</p>

<p>So they stated dutifully adding `<code>| html</code>` all over the place. But that's stupid. It's playing whackamole because this sort of issue will keep cropping up again and again, often only to be noticed after it's abused.</p>

<p>However now it's really easy to fix this by having the html filter applied to <strong>all</strong> tokens in a template:<br />
<script src="https://gist.github.com/1087694.js"></script></p>

<p>To break this down:</p>

<p>This is your typical TT view for your Catalyst app. It uses on Catalyst::View::TT as base class, but defines v0.37 as a minimum. This version (released today) supports the CLASS parameter, which allows you to set the class to be used to create the TT object.</p>

<p>That makes it possible to use <a href="http://metacpan.org/module/Template::AutoFilter">Template::AutoFilter</a> instead of pure Template. This is great because T::AF automatically applies a filter (html by default) to any unfiltered template tokens. (Excluding a bunch of control tokens that either pull in other templates or have no output.)</p>

<p>What this means is that with this little code snippet above you have a view that automatically converts any user input so all html elements are rendered as entities and displayed plainly to the user instead of being interpreted by the browser. Of course, you'll want some parts to not be filtered, and that's easy to do, since you can either apply some other filter, or just add `<code>| none</code>` to skip the auto-filtering.</p>

<p><strong>This means there's no way for an attacker to inject html or javascript into the template-driven parts of your website unless you explicitly enable it.</strong></p>]]>
        
    </content>
</entry>

<entry>
    <title>Why are people asking for a Perl name change again?</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/06/why-are-people-asking-for-a-perl-name-change-again.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.1908</id>

    <published>2011-06-27T07:22:19Z</published>
    <updated>2011-06-27T07:43:15Z</updated>

    <summary>There has recently recently been an increase people asking, seriously or in jest, for Perl 5 and/or Perl 6 to be renamed and others offering rebuffals of various types. You could say a heated debate seems to be going on....</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p>There has recently recently been an increase people asking, seriously or in jest, for Perl 5 and/or Perl 6 to be renamed and others offering rebuffals of various types. You could say a heated debate seems to be going on.</p>

<p>However, one thing stands out here: It does not seem to be clear to either party exactly why the party is saying what it is saying. And when the realization arrives, some realize that it should be fairly obvious and stop arguing, but do not make their realization public, leaving others to make the same mistake.</p>

<p>As such, i'll try to put it into the most simple words i can here:</p>

<p>The existence of Perl 6 means that for the decision makers in IT, the managers and CEOs who are not even programmers, Perl 5 appears to be obsolete.</p>

<p>This is not a language issue, this is not a feature issue, this is not a community issue. This is entirely an issue of marketing Perl 5 to the people who control the money, because they decide which developers to hire and what languages to train their developers in and which language to use in their next project. Many of them will not make the decision based on how shiny Moose, Dancer or Mojolicious are, or how many modules there are on CPAN. They will make the decision based on gut feeling and on how well they can sell it to shareholders.</p>

<p>The name Perl 6 implies to non-technical people that it is newer and better than Perl 5 and that Perl 5 is abandoned and a waste of time and money to invest in. There is a lot of vibrancy and activity in the Perl 5 community, with new tools and toys springing up weekly and improvements being made to the core regularly, but this is only visible to programmers, people who are on the ground and working on it.</p>

<p>People who ask for name changes do not do it so they can effect great upsets in the Perl development. Perl 5 has had a great many upsets since it was first called Perl 5.</p>

<p><strong>People ask for name changes so they can show the rest of the world just how alive Perl 5 really is.</strong></p>]]>
        
    </content>
</entry>

<entry>
    <title>Dancing on Windows in Stop-Motion</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/mithaldu/2011/05/dancing-on-windows-in-stop-motion.html" />
    <id>tag:blogs.perl.org,2011:/users/mithaldu//415.1741</id>

    <published>2011-05-07T09:26:03Z</published>
    <updated>2011-05-08T07:08:59Z</updated>

    <summary>In short: Perl debugger is awesome. Komodo IDE makes it even more awesome and can play with the guts of a Plack web-app while the web-app is running on a web server. And now all of this now works on...</summary>
    <author>
        <name>Mithaldu</name>
        <uri>http://cat.eatsmou.se</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/mithaldu/">
        <![CDATA[<p>In short:</p>

<p>Perl debugger is awesome. Komodo IDE makes it even more awesome and can play with the guts of a Plack web-app while the web-app is running on a web server. And now all of this now works on Windows too, by updating Plack and applying a tiny patch to Komodo.</p>

<p>Recently I wanted to do some Dancer development on Windows. For me web development means making use of some fairly powerful tools in order to remove delays and increase the turnaround speed. Sadly the state of the stack under Dancer, as well as one of these tools hampered my efforts, leading me to fix them. In following I will lay out the tools, the needed fixes and my web development workflow.</p>

<p>My favourite tool in the vast toolbox Perl provides is the debugger. Simply adding '-d' to the command line permits stepping through a program statement by statement, halt at any line, halt only when certain conditions are fulfilled and most importantly: It permits examination of the content of any variable at runtime by simply issueing 'x %var' and even to execute arbitrary code at runtime to change variable contents, thus allowing more complex analysis on variable states or change on the program execution flow.</p>

<p>In short: It allows full insight and control over any Perl program.</p>

<p>However, as it is merely a command-line tool, all these powers are not as speedily accessible as they could be. To find out when a certain variable is changed in a program it is necessary to reissue the x-command after every statement. In order to run a program under certain conditions it is necessary to rebuild them on the command line. This can be fairly time-consuming when trying to reproduce the circumstances of a web-application, as %ENV needs to be adapted, as well as cookies provided.</p>

<p>Both of these problems are solved by Komodo IDE.</p>

<p>It is able to start Perl programs in debug mode and wraps UI elements around the debugger controls that automate certain things. It recognizes lexically close variables, provides them in a list and automatically issues the x-command on them at each step, making it possible to literally watch the program state change while stepping through it. It also provides alternate views for global variables, special variables like the contents of @_ and most importantly watches on arbitrary Perl expressions. This makes debugging a process much faster than working with the debugger manually.</p>

<p>Secondly it provides a network interface that programs running in debug mode can connect to, permitting remote debugging. Adding a '-d' to the hashbang line at the start of a Perl program and having the %ENV configured to load the Komodo-provided debugging library (simply a module in the vein of Devel::Cover, NYTProf, etc.) makes it possible to have a program running on a web server in London connect to Komodo IDE on a workstation in Berlin, enabling all the aforementioned inspection and control.</p>

<p>For me this means that my development environment consists of any web server with a few configuration settings to tweak %ENV so the Komodo debug library is loaded. Perl programs are run in CGI mode through Plack, so I can toggle them into debug mode whenever I wish without needing to restart the server. Finally, Komodo IDE on my development platform to accept any debug requests sent by the Perl programs started by the web server. In production things are run with the FastCGI handler, but even there i can switch to the CGI handler at any time if i need to look into the guts of my application.</p>

<p>This is where the first problem occurred: Trying to run Dancer through Plack on Windows resulted in spurious server errors and corrupted or truncated pages when using the CGI handler. This was caused by Perl's (unneeded and pointless) newline mangling on Win32, since it meant the HTTP headers sent by Plack were wrong and binary data was corrupted. After figuring this out, a patch issued to miyagawa was integrated in less than two day and the issue fixed in Plack 0.9977.</p>

<p>Then the second problem became obvious: Fixing the newline mangling necessitated a change that Komodo's debugger library didn't know how to deal with, resulting in the mangling staying activated. Luckily it was easy to fix and a patch sent to Activestate, which was accepted for Komodo IDE 7. If you do not use the nightlies or alphas, you can also apply the patch yourself: <a href="https://gist.github.com/960360">https://gist.github.com/960360</a></p>

<p>Simply by making sure that you have the latest Plack and the above patch applied and you can do ridiculously fast web development with Komodo IDE, using powerful and convient debugging features. (And all of the above really applies for any framework using Plack.)</p>

<p>Thanks to p5p, Miyagawa and Activestate for making such tools available and even more so to the latter two for acting fast on patches.</p>]]>
        
    </content>
</entry>

</feed>
