<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>initself</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/initself/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/initself//190</id>
    <updated>2011-09-30T18:48:30Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Initself&apos;s Retarded Guide to Building a Package</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/2011/09/initselfs-retarded-guide-to-building-a-package.html" />
    <id>tag:blogs.perl.org,2011:/users/initself//190.2242</id>

    <published>2011-09-30T18:20:38Z</published>
    <updated>2011-09-30T18:48:30Z</updated>

    <summary>To build a package, use Module::Install, ya turkey! cpan Module::Install Make a directory for your package to reside: mkdir /home/you/My-Package Put your module in the &apos;lib&apos; directory. This is where all your code is going to live. mkdir lib mkdir...</summary>
    <author>
        <name>initself</name>
        <uri>http://mikebaas.org</uri>
    </author>
    
    <category term="retardedpackage" label="retarded package" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/initself/">
        <![CDATA[<p>To build a package, use <a href="http://search.cpan.org/~adamk/Module-Install-1.02/lib/Module/Install.pod#Writing_Module::Install_Installers">Module::Install</a>, ya turkey!</p>

<pre><code>cpan Module::Install
</code></pre>

<p><br /> 
Make a directory for your package to reside:</p>

<pre><code>mkdir /home/you/My-Package
</code></pre>

<p><br />
Put your module in the 'lib' directory.  This is where all your code is going to live.</p>

<pre><code>mkdir lib
mkdir My
touch My/Package.pm
</code></pre>

<p><br /> 
Put your code in My/Package.pm, or copy the file you already wrote here.</p>

<p>Then, create a Makefile.PL in /home/you/My-Package:</p>

<pre><code>use inc::Module::Install;

# Define metadata
name           'My-Package';
perl_version   '5.006';
version        '0.01';
license        'perl';

# Specific dependencies
test_requires  'Test::More'  =&gt; '0.42';

WriteAll;
</code></pre>

<p><br /> 
Then, just run your new shiny file, pal!</p>

<pre><code>perl Makefile.PL &amp;&amp; make &amp;&amp; make install &amp;&amp; make clean &amp;&amp; rm Makefile.old
</code></pre>

<p><br /> 
While your at it, put that in a file called 'install.sh' so you can execute that each time you install it.  You've gotta be root to run this sucker!</p>

<pre><code>sudo sh install.sh
</code></pre>

<p><br /> 
Afterwards, your directory will looks like this:</p>

<pre><code>inc/  install.sh*  lib/ Makefile.PL  META.yml
</code></pre>

<p><br /> 
You're installed!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Initself&apos;s Retarded Guide to Creating a Package</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/2011/09/initselfs-retarded-guide-to-creating-a-package.html" />
    <id>tag:blogs.perl.org,2011:/users/initself//190.2241</id>

    <published>2011-09-30T17:59:51Z</published>
    <updated>2011-09-30T18:14:48Z</updated>

    <summary>Here&apos;s my definitive guide to creating a Perl package (non-OO) for retards. # where package is My/Package.pm package My::Package; # You can put it in the root directory if you wish # and refer to it just as Package.pm, but...</summary>
    <author>
        <name>initself</name>
        <uri>http://mikebaas.org</uri>
    </author>
    
    <category term="retardedpackage" label="retarded package" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/initself/">
        <![CDATA[<p>Here's my definitive guide to creating a Perl package (non-OO) for retards.</p>

<pre><code># where package is My/Package.pm
package My::Package;

# You can put it in the root directory if you wish
# and refer to it just as Package.pm, but try create your own namespace 
# if you can
#
# package Package;

use warnings;
use strict;
use base 'Exporter';

# you will have your sub automatically accessible
our @EXPORT = qw(your_sub); 

# Or, you can choose to explicitly import your subroutine name like
# this in your calling code: use My::Package qw/your_sub/
#
# our @EXPORT_OK = qw(your_sub);  

sub your_sub {
  return "foo";
}

1; # return a true value at the end of your module to keep things happy
</code></pre>

<p>Here's how you use it.</p>

<pre><code>use My::Package;
my $bar = your_sub(); # $bar is now 'foo'
</code></pre>
]]>
        

    </content>
</entry>

<entry>
    <title>Listing All Installed Programs in Windows XP</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/2010/11/listing-all-installed-programs-in-windows-xp.html" />
    <id>tag:blogs.perl.org,2010:/users/initself//190.1147</id>

    <published>2010-11-03T05:36:20Z</published>
    <updated>2010-11-03T05:51:47Z</updated>

    <summary>I wanted to get a list of all the programs installed on my computer listed in &apos;Add or Remove Programs&apos; in the Control Panel in Windows XP. Win32::TieRegistry provided a nice way to do this. #!perl use warnings; use strict;...</summary>
    <author>
        <name>initself</name>
        <uri>http://mikebaas.org</uri>
    </author>
    
    <category term="windows" label="windows" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/initself/">
        <![CDATA[<p>I wanted to get a list of all the programs installed on my computer listed in 'Add or Remove Programs' in the Control Panel in Windows XP.  <a href="http://search.cpan.org/~adamk/Win32-TieRegistry-0.26/lib/Win32/TieRegistry.pm" title="Win32::TieRegistry">Win32::TieRegistry</a> provided a nice way to do this.</p>

<pre><code>#!perl
use warnings;
use strict;
use Data::Dumper;

my $Registry;

use Win32::TieRegistry (
  Delimiter   =&gt; "/",
  ArrayValues =&gt; 1,
  TiedRef     =&gt; \$Registry,
 );

my $regkey = 'HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Uninstall/';

my @install_names;
foreach my $software ( values %{$Registry-&gt;{$regkey}} ) {
  next unless my $software = $software-&gt;{DisplayName};
  next unless $software-&gt;[0];
  push @install_names, $software-&gt;[0];
}

print "$_\n" for sort {lc $a cmp lc $b} @install_names;
</code></pre>

<p>Win32::TieRegistry installs along with <a href="http://strawberryperl.com/">Strawberry Perl</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>How Open Source is Possible (at least one part)</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/2010/04/how-open-source-is-possible-at-least-one-part.html" />
    <id>tag:blogs.perl.org,2010:/users/initself//190.509</id>

    <published>2010-04-28T16:36:39Z</published>
    <updated>2010-04-28T16:42:03Z</updated>

    <summary>Often times I find myself wondering how Open Source is even possible. How does something so amazing as CPAN get built and maintained and perfected? I think I figured it out, at least one part of it. It is possible...</summary>
    <author>
        <name>initself</name>
        <uri>http://mikebaas.org</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/initself/">
        <![CDATA[<p>Often times I find myself wondering how Open Source is even possible.  How does something so amazing as CPAN get built and maintained and perfected?</p>

<p>I think I figured it out, at least one part of it.</p>

<p>It is possible because there are a lot of smart people out there being employed by employers who have no real idea of what is required in any given project.  Therefore, programmers who have </p>

<ul>
	<li>tremendous flexibility to get "whatever they want" done to accomplish a given project</li>
        <li>employers/managers who don't know the first thing about what is required to create an application</li>
</ul>

<p>can contribute amazing feats of collective heroism day in and day out, without having to worry about how they are going to pay for new shoes.</p>

<p>And then of course there is boredom.  And the sheer enjoyment of coding.  And altruism.</p>]]>
        
    </content>
</entry>

<entry>
    <title>POE Palm Sync Monitor</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/2010/02/poe-palm-sync-monitor.html" />
    <id>tag:blogs.perl.org,2010:/users/initself//190.250</id>

    <published>2010-02-06T07:04:09Z</published>
    <updated>2010-09-28T02:33:44Z</updated>

    <summary>I am weird. i have a Motorola Droid and a first generation iPhone which I use on WiFi only. But I really can&apos;t get myself to use either of them for task management. Nothing beats the feel of my Palm...</summary>
    <author>
        <name>initself</name>
        <uri>http://mikebaas.org</uri>
    </author>
    
    <category term="poepalm" label="POE Palm" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/initself/">
        <![CDATA[<p>I am weird.</p>

<p>i have a <a href="http://www.motorola.com/Consumers/US-EN/Consumer-Product-and-Services/Mobile-Phones/Motorola-DROID-US-EN?localeId=33">Motorola Droid</a> and a first generation <a href="http://en.wikipedia.org/wiki/IPhone">iPhone</a> which I use on WiFi only. But I really can't get myself to use either of them for task management.</p>

<p>Nothing beats the feel of my <a href="http://en.wikipedia.org/wiki/Tungsten_%28handheld%29#Tungsten_C">Palm Tungsten C</a> keyboard.  And nothing really beats the simplicity of the Palm ToDo List.  Well, not really nothing, but you know what I mean.</p>

<p>I was surprised and happy to notice active development still taking place on <a href="http://search.cpan.org/dist/p5-Palm/">p5-Palm</a>.  Today, I decided to resurrect an old project I had started to create a Palm Sync daemon on my home server.</p>

<p>First, I confirmed that <a href="http://www.pilot-link.org/">pilot-link</a> was up and running on my server.  Next, I refreshed my memory on the commands used to run a WiFi sync.The first step is to make sure the user of the Tungsten C and the user of pilot-link are one and the same.  This overwrites the user on the device, so proceed with caution.</p>

<p><code>pilot-install-user -p net:any -i 1000 -u mike</code></p>

<p>After setting the user, make a full backup of the device, where 'backup' is a directory.</p>

<p><code>pilot-xfer -p net:any -b backup</code></p>

<p>You may need to include an exclude file list using '-e exclude.txt', where 'exclude.txt' is a file containing the Palm files to exclude from a backup (or a sync).  When I first tried this, I ran into 'Segmentation fault' errors during backup. An upgrade to pilot-link-0.12.0-pre4 did nothing to alleviate the problem. I had to exclude the file (ImgFile-Foto.prc) causing the segmentation fault from the back up process (see <a href="http://www.jpilot.org/pipermail/jpilot/2005-January/004609.html">http://www.jpilot.org/pipermail/jpilot/2005-January/004609.html</a>).</p>

<p>Finally, you can sync the device like so:</p>

<p><code>pilot-xfer -p net:any -s backup</code></p>

<p>Now I needed a way to keep my pilot-xref sync process running on my server until Kingdom Come.  In the end, I decided to turn to an old trusty friend for help in this matter, <a href="http://search.cpan.org/dist/POE/">POE</a>.</p>

<p>I knew I needed something to monitor the sync process running on my server to determine if the sync process was up and listening for my Palm or if it needed to be started.  Because I am not the sharpest tool in the shed, my first impulse was to hack together something that parsed the output of <code>ps -ef</code>.  Then someone on #perl on Freenode reminded me that it's rarely wise to write something that parses text meant for human consumption.  <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/">mst</a> was kind enough to point out <a href="http://search.cpan.org/dist/Proc-ProcessTable/">Proc::ProcessTable</a>.  This would easily match the name of my sync command in the process table to let me know if my script was running or not.  But before cobbling this together, I took one more tour through the glorious <a href="http://search.cpan.org/">CPAN</a> and stumbled upon <a href="http://search.cpan.org/~nuffin/POE-Component-Supervisor-0.05/lib/POE/Component/Supervisor/Supervised/Proc.pm">POE::Component::Supervisor::Supervised::Proc</a>.  Although not very aptly named, this module was to do the trick, <strong>very easily</strong>.</p>

<pre><code>#!/usr/bin/perl
use warnings;
use strict;
use POE;
use POE::Component::Supervisor;
use POE::Component::Supervisor::Supervised::Proc;
my $program = "pilot-xfer -p net:any -s backup";
POE::Component::Supervisor->new(
    children => [
        POE::Component::Supervisor::Supervised::Proc->new(
            program => [$program],
            restart_policy => "permanent",
        ),
    ],
);
</code></pre>

<p>Sometimes the hardest part of programming is finding out what things are called on CPAN.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Perl is Amazing!</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/initself/2009/12/perl-is-amazing.html" />
    <id>tag:blogs.perl.org,2009:/users/initself//190.139</id>

    <published>2009-12-26T17:41:10Z</published>
    <updated>2010-02-06T08:08:33Z</updated>

    <summary>I wouldn&apos;t be able to live if it weren&apos;t for Perl! Perl5, that is. Linux is my IDE. Perl5 is my VM. CPAN is my language. (thanks, mst)...</summary>
    <author>
        <name>initself</name>
        <uri>http://mikebaas.org</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/initself/">
        <![CDATA[<p>I wouldn't be able to live if it weren't for Perl!  Perl5, that is.</p>

<p>Linux is my IDE.<br />
Perl5 is my VM. <br />
CPAN is my language.<br />
(thanks, <a href="http://www.shadowcat.co.uk/blog/matt-s-trout/">mst</a>)</p>]]>
        
    </content>
</entry>

</feed>
