<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brain Goo &#187; perl</title>
	<atom:link href="http://www.popmartian.com/tipsntricks/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.popmartian.com/tipsntricks</link>
	<description>Carpe Crap 'em</description>
	<lastBuildDate>Mon, 10 Oct 2011 14:42:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Build A Custom PERL Installation</title>
		<link>http://www.popmartian.com/tipsntricks/2011/04/11/build-a-custom-perl-installation/</link>
		<comments>http://www.popmartian.com/tipsntricks/2011/04/11/build-a-custom-perl-installation/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 18:55:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/?p=198</guid>
		<description><![CDATA[If you want to build a PERL installation that is separate from your standard PERL, you can compile one, complete with CPAN support. Just follow these steps: mkdir /custom/perl/ cd /custom/perl/ curl -O http://www.cpan.org/src/perl-5.12.3.tar.gz mkdir perl-5_12_3 gunzip perl-5.12.3.tar.gz tar -xf perl-5.12.3.tar cd perl-5.12.3 ./Configure -d -Dprefix=/custom/perl/perl-5_12_3 make make test make install /custom/perl/perl-5_12_3/bin/perl -v /custom/perl/perl-5_12_3/bin/perl -e [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to build a PERL installation that is separate from your standard PERL, you can compile one, complete with CPAN support.  Just follow these steps:</p>
<ol>
<li>mkdir /custom/perl/</li>
<li>cd /custom/perl/</li>
<li>curl -O http://www.cpan.org/src/perl-5.12.3.tar.gz</li>
<li>mkdir perl-5_12_3</li>
<li>gunzip perl-5.12.3.tar.gz</li>
<li>tar -xf perl-5.12.3.tar</li>
<li>cd perl-5.12.3</li>
<li>./Configure -d -Dprefix=/custom/perl/perl-5_12_3</li>
<li>make</li>
<li>make test</li>
<li>make install</li>
<li>/custom/perl/perl-5_12_3/bin/perl -v</li>
<li>/custom/perl/perl-5_12_3/bin/perl -e &#8216;print &#8220;hello world.\n&#8221;;&#8217;</li>
<li>/custom/perl/perl-5_12_3/bin/perl -MCPAN -e shell
<ul>
<li>Auto configure as much as possible.  Step 15 will edit it.</li>
</ul>
</li>
<li>Edit /custom/perl/perl-5_12_3/lib/5.12.3/CPAN/Config.pm
<ul>
<li>Change the following paths:</li>
<li>&#8216;cpan_home&#8217; =&gt; q[/custom/perl/perl-5_12_3/cpan/],</li>
<li>&#8216;build_dir&#8217; =&gt; q[/custom/perl/perl-5_12_3/cpan/build],</li>
<li>&#8216;histfile&#8217; =&gt; q[/custom/perl/perl-5_12_3/cpan/histfile],</li>
<li>&#8216;keep_source_where&#8217; =&gt; q[/custom/perl/perl-5_12_3/cpan/sources],</li>
<li>&#8221;prefs_dir&#8217; =&gt; q[/custom/perl/perl-5_12_3/cpan/prefs],</li>
<li>&#8221;urllist&#8217; =&gt; [q[ftp://my.cpan.mirror/pub/cpan/]],</li>
</ul>
</li>
<li>Run CPAN and install Bundle::CPAN Bundle::LWP and any required packages</li>
<li>tar -cvf /custom/perl/custom-perl5.12.13.tar /custom/perl/perl-5_12_3/*</li>
<li>gzip /custom/perl/custom-perl5.12.13.tar</li>
<li>Ship custom-perl5.12.13.tar.gz out to your matching architectures or mount it on a shared NAS.</li>
<li>Call it with #!/custom/perl/perl-5_12_3/bin/perl</li>
</ol>
<blockquote><p>Did you find this post useful or have questions or comments?  Please let  me know!</p></blockquote>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=198&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2011/04/11/build-a-custom-perl-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Pass PERL Library Paths From The Environment</title>
		<link>http://www.popmartian.com/tipsntricks/2011/04/11/how-to-pass-perl-library-paths-from-the-environment/</link>
		<comments>http://www.popmartian.com/tipsntricks/2011/04/11/how-to-pass-perl-library-paths-from-the-environment/#comments</comments>
		<pubDate>Mon, 11 Apr 2011 18:07:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/?p=192</guid>
		<description><![CDATA[You can have PERL look in different places for libraries and modules using a number of methods. If you find yourself using a custom PERL module repository, you can make sure your PERL programs always reference it without touching the code. What we&#8217;re doing in a nutshell is telling PERL to push values on to [...]]]></description>
			<content:encoded><![CDATA[<p>You can have PERL look in different places for libraries and modules using a number of methods.  If you find yourself using a custom PERL module repository, you can make sure your PERL programs always reference it without touching the code.</p>
<p>What we&#8217;re doing in a nutshell is telling PERL to push values on to the @INC array before loading any modules.  You can do this on the command line, in your PERL code or with the environment variable <code>PERL5LIB</code>.</p>
<p><code>PERL5LIB</code> can contain more than one value.  Just set it in you .bashrc file or wherever you see fit.  This method works in bash:</p>
<p><code>export PERL5LIB=/first/path/to/libs"${PERL5LIB:+:$PERL5LIB}"<br />
export PERL5LIB=/second/path/to/libs"${PERL5LIB:+:$PERL5LIB}"<br />
export PERL5LIB=/third/path/to/libs"${PERL5LIB:+:$PERL5LIB}"</code></p>
<p>You can check what PERL is going to use by printing out the contents of @INC.  <a href="http://www.popmartian.com/tipsntricks/2009/02/06/perl-how-to-print-a-list-without-a-loop/">You can print an array without a loop using join() as I blogged about before</a>:</p>
<p><code>perl -e 'print join "\n", @INC;'</code></p>
<p>Let&#8217;s put it together:<br />
~$ <code>perl -e 'print join "\n", @INC;'</code><br />
<em>/etc/perl<br />
/usr/local/lib/perl/5.10.0<br />
/usr/local/share/perl/5.10.0<br />
/usr/lib/perl5<br />
/usr/share/perl5<br />
/usr/lib/perl/5.10<br />
/usr/share/perl/5.10<br />
/usr/local/lib/site_perl<br />
.</em></p>
<p>~$ <code>env|grep -i perl</code><br />
~$</p>
<p>~$ <code>export PERL5LIB=/first/path/to/libs"${PERL5LIB:+:$PERL5LIB}"</code><br />
~$ <code>export PERL5LIB=/second/path/to/libs"${PERL5LIB:+:$PERL5LIB}"</code><br />
~$ <code>export PERL5LIB=/third/path/to/libs"${PERL5LIB:+:$PERL5LIB}"</code></p>
<p>~$ <code>env|grep -i perl</code><br />
<em>PERL5LIB=/third/path/to/libs:/second/path/to/libs:/first/path/to/libs</em></p>
<p>~$ <code>perl -e 'print join "\n", @INC;'</code><br />
<em>/third/path/to/libs<br />
/second/path/to/libs<br />
/first/path/to/libs<br />
/etc/perl<br />
/usr/local/lib/perl/5.10.0<br />
/usr/local/share/perl/5.10.0<br />
/usr/lib/perl5<br />
/usr/share/perl5<br />
/usr/lib/perl/5.10<br />
/usr/share/perl/5.10<br />
/usr/local/lib/site_perl<br />
.</em></p>
<p>And there it is.  Your PERL apps will look in those locations starting from the top.</p>
<blockquote><p>Did you find this post useful or have questions or comments?  Please let  me know!</p></blockquote>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=192&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2011/04/11/how-to-pass-perl-library-paths-from-the-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Prevent A PERL Script From Running As Root</title>
		<link>http://www.popmartian.com/tipsntricks/2011/03/29/how-to-prevent-a-perl-script-from-running-as-root/</link>
		<comments>http://www.popmartian.com/tipsntricks/2011/03/29/how-to-prevent-a-perl-script-from-running-as-root/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 03:11:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/?p=184</guid>
		<description><![CDATA[At or near the top of your app, before it executes anything sensitive, place the following code: if((getpwuid($]]></description>
			<content:encoded><![CDATA[<p>At or near the top of your app, before it executes anything sensitive, place the following code:</p>
<p><code>if((getpwuid($<) eq "root") || ($< == 0)){<br />
    print STDOUT "Cannot run as root!\n";<br />
    exit(1);<br />
}</code></p>
<blockquote><p>Did you find this post useful or have questions or comments?  Please let  me know!</p></blockquote>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=184&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2011/03/29/how-to-prevent-a-perl-script-from-running-as-root/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PERL How To Print A List Without A Loop</title>
		<link>http://www.popmartian.com/tipsntricks/2009/02/06/perl-how-to-print-a-list-without-a-loop/</link>
		<comments>http://www.popmartian.com/tipsntricks/2009/02/06/perl-how-to-print-a-list-without-a-loop/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 16:47:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/?p=71</guid>
		<description><![CDATA[PERL has a built-in function called join() that will concatenate a list with a given string. The official perldoc states: join EXPR,LIST Joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns that new string. Example: $rec = join(':', $login,$passwd,$uid,$gid,$gcos,$home,$shell); From the code example, you [...]]]></description>
			<content:encoded><![CDATA[<p>PERL has a built-in function called join() that will concatenate a list with a given string.  The official perldoc states:</p>
<p><em><strong>join EXPR,LIST</strong><br />
Joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns that new string. Example:</em><br />
<code>$rec = join(':', $login,$passwd,$uid,$gid,$gcos,$home,$shell);</code></p>
<p>From the code example, you can make CSV output and all kinds of goodies, but what the doc misses and the example doesn&#8217;t show is that combining join() with a print statement makes writing lists to STDOUT or a file handle a snap.  This is where join() really shines.</p>
<p>Example:</p>
<p><em><strong>Code</strong></em><br />
<code>@names = ('Mark', 'Jim', 'Bob','Mary','Steven','Gomer');<br />
print join("\n", @names);</code></p>
<p><em><strong>Output</strong><br />
Mark<br />
Jim<br />
Bob<br />
Mary<br />
Steven<br />
Gomer</em></p>
<p>Note that this will NOT print a final or beginning string.  Join() concatenates the elements, meaning it puts the string value BETWEEN the list elements.</p>
<blockquote><p>Did you find this post useful or have questions or comments?  Please let me know!</p></blockquote>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=71&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2009/02/06/perl-how-to-print-a-list-without-a-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl howto push a hash onto an array</title>
		<link>http://www.popmartian.com/tipsntricks/2008/08/12/perl-howto-push-a-hash-onto-an-array/</link>
		<comments>http://www.popmartian.com/tipsntricks/2008/08/12/perl-howto-push-a-hash-onto-an-array/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 20:59:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/?p=24</guid>
		<description><![CDATA[use Data::Dumper; my @array; push @array, {'key1' =&#62; 'value1', 'key2' =&#62; 'value2'}; push @array, {'key1' =&#62; 'value1', 'key2' =&#62; 'value2'}; push @array, {'key1' =&#62; 'value1', 'key2' =&#62; 'value2'}; print Dumper(@array); Will give you: $VAR1 = { 'key2' =&#62; 'value2', 'key1' =&#62; 'value1' }; $VAR2 = { 'key2' =&#62; 'value2', 'key1' =&#62; 'value1' }; $VAR3 = [...]]]></description>
			<content:encoded><![CDATA[<p><code>use Data::Dumper;<br />
my @array;<br />
push @array, {'key1' =&gt; 'value1', 'key2' =&gt; 'value2'};<br />
push @array, {'key1' =&gt; 'value1', 'key2' =&gt; 'value2'};<br />
push @array, {'key1' =&gt; 'value1', 'key2' =&gt; 'value2'};<br />
print Dumper(@array);</code></p>
<p>Will give you:<br />
<code><br />
$VAR1 = {<br />
'key2' =&gt; 'value2',<br />
'key1' =&gt; 'value1'<br />
};<br />
$VAR2 = {<br />
'key2' =&gt; 'value2',<br />
'key1' =&gt; 'value1'<br />
};<br />
$VAR3 = {<br />
'key2' =&gt; 'value2',<br />
'key1' =&gt; 'value1'<br />
};<br />
</code></p>
<p>Snazzy!</p>
<blockquote><p>Did you find this post useful or have questions or comments?  Please let me know!</p></blockquote>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=24&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2008/08/12/perl-howto-push-a-hash-onto-an-array/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Perl code to find an IP A in subnet B/C</title>
		<link>http://www.popmartian.com/tipsntricks/2007/06/05/perl-code-to-find-an-ip-a-in-subnet-bc/</link>
		<comments>http://www.popmartian.com/tipsntricks/2007/06/05/perl-code-to-find-an-ip-a-in-subnet-bc/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 22:14:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[How Tos]]></category>
		<category><![CDATA[ip addressing]]></category>
		<category><![CDATA[ipv4]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.popmartian.com/tipsntricks/2007/06/05/perl-code-to-find-an-ip-a-in-subnet-bc/</guid>
		<description><![CDATA[my $ip = '1.2.3.4'; my $block1 = '1.2.3.0/27'; if(checkip($ip, $block1)) { print STDOUT "$ip is in $block1\n"; } else { print STDOUT "$ip is not in $block1\n"; } sub checkip() { my $ip = shift; my $block = shift; @ip1 = split(/\./, $ip); $ip1 = $ip1[0] * 2**24 + $ip1[1] * 2**16 + $ip1[2] * [...]]]></description>
			<content:encoded><![CDATA[<pre>
my $ip = '1.2.3.4';
my $block1 = '1.2.3.0/27';

if(checkip($ip, $block1)) {
    print STDOUT "$ip is in $block1\n";
}
else {
    print STDOUT "$ip is not in $block1\n";
}

sub checkip() {
    my $ip = shift;
    my $block = shift;

    @ip1 = split(/\./, $ip);
    $ip1 = $ip1[0] * 2**24 + $ip1[1] * 2**16 + $ip1[2] * 2**8 + $ip1[3];
    my @temp = split(/\//, $block);

    $ip2 = $temp[0];
    my $netmask = $temp[1];

    @ip2 = split(/\./, $ip2);
    $ip2 = $ip2[0] * 2**24 + $ip2[1] * 2**16 + $ip2[2] * 2**8 + $ip2[3];

    if( $ip1 >> (32-$netmask) == $ip2 >> (32-$netmask) ) {
            return 1;
    }
    return 0;
}</pre>
<img src="http://www.popmartian.com/tipsntricks/?ak_action=api_record_view&id=8&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.popmartian.com/tipsntricks/2007/06/05/perl-code-to-find-an-ip-a-in-subnet-bc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

