<?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>Marius van Witzenburg &#187; Perl</title>
	<atom:link href="http://mariusvw.com/tag/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://mariusvw.com</link>
	<description>We fight for our survival, we fight!</description>
	<lastBuildDate>Tue, 27 Dec 2011 10:35:27 +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>How to use the exec() and system() function and capture the returned output in Perl</title>
		<link>http://mariusvw.com/2011/06/14/how-to-use-the-exec-and-system-function-and-capture-the-returned-output-in-perl/</link>
		<comments>http://mariusvw.com/2011/06/14/how-to-use-the-exec-and-system-function-and-capture-the-returned-output-in-perl/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 19:11:14 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Backticks]]></category>
		<category><![CDATA[Exec]]></category>
		<category><![CDATA[Output]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://kitara.nl/?p=334</guid>
		<description><![CDATA[When you want to execute a program you sometimes want to use the result of the program you executed. exec&#40;PROGRAM&#41;; $result = system&#40;PROGRAM&#41;; Both Perl's exec() function and system() function execute a system shell command. The big difference is that system() creates a fork process and waits to see if the command succeeds or fails [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to execute a program you sometimes want to use the result of the program you executed.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">exec</span><span style="color: #009900;">&#40;</span>PROGRAM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000066;">system</span><span style="color: #009900;">&#40;</span>PROGRAM<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Both Perl's <strong>exec()</strong> function and <strong>system()</strong> function execute a system shell command. The big difference is that <strong>system()</strong> creates a fork process and waits to see if the command succeeds or fails - returning a value. <strong>exec()</strong> does not return anything, it simply executes the command. Neither of these commands should be used to capture the output of a system call. If your goal is to capture output, you should use the <strong>backtick operator</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$result</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`PROGRAM`</span><span style="color: #339933;">;</span></pre></div></div>

<p>Found this information in a post by <a href="http://perl.about.com/bio/Kirk-Brown-16393.htm">Kirk Brown</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2011/06/14/how-to-use-the-exec-and-system-function-and-capture-the-returned-output-in-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to trim whitespace with a custom subroutine in Perl</title>
		<link>http://mariusvw.com/2011/06/14/how-to-trim-whitespace-with-a-custom-subroutine-in-perl/</link>
		<comments>http://mariusvw.com/2011/06/14/how-to-trim-whitespace-with-a-custom-subroutine-in-perl/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 18:00:50 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Ltrim]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Rtrim]]></category>
		<category><![CDATA[Spaces]]></category>
		<category><![CDATA[Subroutine]]></category>
		<category><![CDATA[Tabs]]></category>
		<category><![CDATA[Trim]]></category>
		<category><![CDATA[Whitespace]]></category>

		<guid isPermaLink="false">http://kitara.nl/?p=313</guid>
		<description><![CDATA[Since perl does not have a built-in trim function (yet). Use the subroutine below to trim whitespace (spaces and tabs) from the beginning and end of a string in Perl. This function is directly based on the Perl FAQ entry, How do I strip blank space from the beginning/end of a string?. The ltrim and [...]]]></description>
			<content:encoded><![CDATA[<p>Since perl does not have a built-in trim function (yet). Use the subroutine below to trim whitespace (spaces and tabs) from the beginning and end of a string in Perl. This function is directly based on the Perl FAQ entry, How do I strip blank space from the beginning/end of a string?. The ltrim and rtrim functions can trim leading or trailing whitespace.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Declare the subroutines</span>
<span style="color: #000000; font-weight: bold;">sub</span> trim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">sub</span> ltrim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">sub</span> rtrim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Create a test string</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$string</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;  <span style="color: #000099; font-weight: bold;">\t</span>  Hello world!   &quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Here is how to output the trimmed text &quot;Hello world!&quot;</span>
<span style="color: #000066;">print</span> trim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> ltrim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> rtrim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Perl trim function to remove whitespace from the start and end of the string</span>
<span style="color: #000000; font-weight: bold;">sub</span> trim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$string</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s+//</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$string</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s+$//</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;"># Left trim function to remove leading whitespace</span>
<span style="color: #000000; font-weight: bold;">sub</span> ltrim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$string</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/^\s+//</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;"># Right trim function to remove trailing whitespace</span>
<span style="color: #000000; font-weight: bold;">sub</span> rtrim<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$string</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\s+$//</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">return</span> <span style="color: #0000ff;">$string</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2011/06/14/how-to-trim-whitespace-with-a-custom-subroutine-in-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to send a message to your iPhone via Pushme.to with PHP or Bash and Curl</title>
		<link>http://mariusvw.com/2011/06/14/how-to-send-a-message-to-your-iphone-via-pushme-to-with-php-or-bash-and-curl/</link>
		<comments>http://mariusvw.com/2011/06/14/how-to-send-a-message-to-your-iphone-via-pushme-to-with-php-or-bash-and-curl/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 12:05:21 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Curl]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[GEOM]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pushme]]></category>
		<category><![CDATA[S.M.A.R.T.]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[SMS]]></category>
		<category><![CDATA[Text]]></category>

		<guid isPermaLink="false">http://kitara.nl/?p=241</guid>
		<description><![CDATA[After having Pushme.to installed on my iPhone for over 3 months now I finally had the time to work on some scrips to make it work in different languages for use on servers that I manage. The PHP version is the less version I use but may be handy for some people. PHP Version: function [...]]]></description>
			<content:encoded><![CDATA[<p>After having <a href="http://pushme.to/">Pushme.to</a> installed on my <a href="http://www.apple.com/iphone/">iPhone</a> for over 3 months now I finally had the time to work on some scrips to make it work in different languages for use on servers that I manage.</p>
<p>The <a href="http://php.net/">PHP</a> version is the less version I use but may be handy for some people.</p>
<p><strong>PHP Version</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> pushMeTo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$signature</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$curl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://pushme.to/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$username</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POST<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #339933;">,</span> CURLOPT_POSTFIELDS<span style="color: #339933;">,</span> <span style="color: #0000ff;">'message='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;signature='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$signature</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$curl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
pushMeTo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Hello world!'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'God'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A more used version is the commandline (<a href="http://www.gnu.org/software/bash/">Bash</a>) version:</p>
<p><strong>Bash version</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">username</span>=<span style="color: #ff0000;">&quot;username&quot;</span>
<span style="color: #007800;">message</span>=<span style="color: #ff0000;">&quot;Hello world&quot;</span>
<span style="color: #007800;">signature</span>=<span style="color: #ff0000;">&quot;God&quot;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>curl <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;message=<span style="color: #007800;">$message</span>&quot;</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;signature=<span style="color: #007800;">$signature</span>&quot;</span> <span style="color: #ff0000;">&quot;http://pushme.to/<span style="color: #007800;">$username</span>/&quot;</span></pre></div></div>

<p>I currently use these for server monitoring on <a href="http://www.freebsd.org/">FreeBSD</a> like the <a href="http://www.freebsd.org/doc/handbook/geom.html">GEOM</a> Raid bay and <a href="http://en.wikipedia.org/wiki/S.M.A.R.T.">S.M.A.R.T.</a> status of the disks and website monitoring which works quite nice. And in case the internet connection drops I have a backup via <a href="http://en.wikipedia.org/wiki/SMS">SMS</a> with a serial connected cellphone. So this should be quite failsafe <img src='http://mariusvw.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>If you have any other language that you want to use such as <a href="http://www.perl.org/">Perl</a> just let me know and I could write it for you.</p>
<p>I hope you find these scripts useful. Happy texting! <img src='http://mariusvw.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2011/06/14/how-to-send-a-message-to-your-iphone-via-pushme-to-with-php-or-bash-and-curl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Test your console if it can display 256 colors with Perl</title>
		<link>http://mariusvw.com/2011/06/12/test-your-console-if-it-can-display-256-colors-with-perl/</link>
		<comments>http://mariusvw.com/2011/06/12/test-your-console-if-it-can-display-256-colors-with-perl/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 10:44:03 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[Colors]]></category>
		<category><![CDATA[Console]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://kitara.nl/?p=123</guid>
		<description><![CDATA[With this script you can test which colors your console can display. You will simply see all the supported colors on your console. #!/usr/bin/perl # Author: Todd Larason &#60;jtl@molehill.org&#62; # $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $ &#160; # use the resources for colors 0-15 - usually more-or-less a # reproduction of the standard [...]]]></description>
			<content:encoded><![CDATA[<p>With this script you can test which colors your console can display.</p>
<p>You will simply see all the supported colors on your console.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
<span style="color: #666666; font-style: italic;"># Author: Todd Larason &lt;jtl@molehill.org&gt;</span>
<span style="color: #666666; font-style: italic;"># $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># use the resources for colors 0-15 - usually more-or-less a</span>
<span style="color: #666666; font-style: italic;"># reproduction of the standard ANSI colors, but possibly more</span>
<span style="color: #666666; font-style: italic;"># pleasing shades</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># colors 16-231 are a 6x6x6 color cube</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$red</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$red</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$red</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$green</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$green</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$green</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$blue</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$blue</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$blue</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b]4;%d;rgb:%2.2x/%2.2x/%2.2x<span style="color: #000099; font-weight: bold;">\x</span>1b<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">,</span>
		   	<span style="color: #cc66cc;">16</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$red</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">36</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$green</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$blue</span><span style="color: #339933;">,</span>
		   	<span style="color: #000066;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$red</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">42.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		   	<span style="color: #000066;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$green</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">42.5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		   	<span style="color: #000066;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$blue</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">42.5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># colors 232-255 are a grayscale ramp, intentionally leaving out</span>
<span style="color: #666666; font-style: italic;"># black and white</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$gray</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$gray</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">24</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$gray</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$level</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$gray</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b]4;%d;rgb:%2.2x/%2.2x/%2.2x<span style="color: #000099; font-weight: bold;">\x</span>1b<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">232</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$gray</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$level</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$level</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$level</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># display the colors</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># first the system ones:</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;System colors:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$color</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$color</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$color</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[48;5;${color}m  &quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[0m<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$color</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$color</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$color</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[48;5;${color}m  &quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[0m<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># now the color cube</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Color cube, 6x6x6:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$green</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$green</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$green</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$red</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$red</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$red</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$blue</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$blue</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$blue</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	<span style="color: #0000ff;">$color</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">16</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$red</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">36</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$green</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">$blue</span><span style="color: #339933;">;</span>
	    	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[48;5;${color}m  &quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[0m &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># now the grayscale ramp</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Grayscale ramp:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$color</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">232</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$color</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">256</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$color</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[48;5;${color}m  &quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\x</span>1b[0m<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2011/06/12/test-your-console-if-it-can-display-256-colors-with-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix inconsistent line ending (EOL) style with find and Perl</title>
		<link>http://mariusvw.com/2010/08/25/how-to-fix-inconsistent-line-ending-eol-style-with-find-and-perl/</link>
		<comments>http://mariusvw.com/2010/08/25/how-to-fix-inconsistent-line-ending-eol-style-with-find-and-perl/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 09:56:24 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[ASP]]></category>
		<category><![CDATA[CFM]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Ending]]></category>
		<category><![CDATA[EOL]]></category>
		<category><![CDATA[Find]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Inconsistent]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[Line]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PL]]></category>
		<category><![CDATA[Replace]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[TXT]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=4967</guid>
		<description><![CDATA[If you work with subversion you might get this error when you got files that have been edited on different operating systems like Windows, Linux, FreeBSD or Mac OS X. Well, the fix is quite simple. You simply replace the wrong line endings with right ones depending of which you want. In my situation I [...]]]></description>
			<content:encoded><![CDATA[<p>If you work with subversion you might get this error when you got files that have been edited on different operating systems like Windows, Linux, FreeBSD or Mac OS X.</p>
<p>Well, the fix is quite simple. You simply replace the wrong line endings with right ones depending of which you want. In my situation I want unix style line endings.</p>
<p>Replace in PHP/JavaScript files:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.php'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-wpe</span> <span style="color: #ff0000;">'s/rn/n/g'</span> <span style="color: #ff0000;">'{}'</span> ;
<span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.php'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-wpe</span> <span style="color: #ff0000;">'s/r/n/g'</span> <span style="color: #ff0000;">'{}'</span> ;
<span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-wpe</span> <span style="color: #ff0000;">'s/rn/n/g'</span> <span style="color: #ff0000;">'{}'</span> ;
<span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-wpe</span> <span style="color: #ff0000;">'s/r/n/g'</span> <span style="color: #ff0000;">'{}'</span> ;</pre></div></div>

<p>In case you want to replace them in multiple file types you can adjust the command. In this example we want to replace in the following file types:</p>
<ol>
<li>asp</li>
<li>cfm</li>
<li>css</li>
<li>html</li>
<li>js</li>
<li>php</li>
<li>pl</li>
<li>txt</li>
</ol>
<p>Use the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.asp'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.cfm'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.css'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.html'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.php'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.pl'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.txt'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-wpe</span> <span style="color: #ff0000;">'s/rn/n/g'</span> <span style="color: #ff0000;">'{}'</span> ;
<span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.asp'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.cfm'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.css'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.html'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.js'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.php'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.pl'</span> <span style="color: #660033;">-or</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.txt'</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-wpe</span> <span style="color: #ff0000;">'s/r/n/g'</span> <span style="color: #ff0000;">'{}'</span> ;</pre></div></div>

<p>Keep in mind, you may use these commands on your own risk. I'm not responsible if you lose your work <img src='http://mariusvw.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Now you should be able to commit your files again <img src='http://mariusvw.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2010/08/25/how-to-fix-inconsistent-line-ending-eol-style-with-find-and-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to upgrade Perl 5.8.x to 5.10.x on FreeBSD.</title>
		<link>http://mariusvw.com/2010/06/08/how-to-upgrade-perl-5-8-x-to-5-10-x-on-freebsd/</link>
		<comments>http://mariusvw.com/2010/06/08/how-to-upgrade-perl-5-8-x-to-5-10-x-on-freebsd/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 08:18:54 +0000</pubDate>
		<dc:creator>mariusvw</dc:creator>
				<category><![CDATA[BSD / Linux / Unix]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Portmaster]]></category>
		<category><![CDATA[Ports]]></category>
		<category><![CDATA[Portupgrade]]></category>
		<category><![CDATA[Updating]]></category>
		<category><![CDATA[Upgrade]]></category>

		<guid isPermaLink="false">http://mariusvw.com/?p=1763</guid>
		<description><![CDATA[In the ports collection you can find /usr/ports/UPDATING. Here you can read how to upgrade Perl 5.8.x to the new release 5.10.x. The description below is copied from the updating file. Note: you might need to manually upgrade some ports after this. For example, I had to recompile APR, Apache and Subversion. Portupgrade users: 0) [...]]]></description>
			<content:encoded><![CDATA[<p>In the ports collection you can find /usr/ports/UPDATING. Here you can read how to upgrade Perl 5.8.x to the new release 5.10.x.</p>
<p>The description below is copied from the updating file.</p>
<p>Note: you might need to manually upgrade some ports after this. For example, I had to recompile APR, Apache and Subversion.</p>
<p><strong>Portupgrade users:</strong><br />
0) Fix pkgdb.db (for safety):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">pkgdb <span style="color: #660033;">-Ff</span></pre></div></div>

<p>1) Reinstall perl with new 5.10:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">DISABLE_CONFLICTS</span>=<span style="color: #000000;">1</span> portupgrade <span style="color: #660033;">-o</span> lang<span style="color: #000000; font-weight: bold;">/</span>perl5.10 <span style="color: #660033;">-f</span> perl-<span style="color: #000000;">5.8</span>.<span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>2) Reinstall everything that depends on Perl:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">portupgrade <span style="color: #660033;">-fr</span> <span style="color: #c20cb9; font-weight: bold;">perl</span></pre></div></div>

<p><strong>Portmaster users:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">DISABLE_CONFLICTS</span>=<span style="color: #000000;">1</span> portmaster <span style="color: #660033;">-o</span> lang<span style="color: #000000; font-weight: bold;">/</span>perl5.10 lang<span style="color: #000000; font-weight: bold;">/</span>perl5.8
portmaster <span style="color: #660033;">-r</span> perl-</pre></div></div>

<p>Note: If the "perl-" glob matches  more than one port you will need to specify the name of the perl directory in /var/db/pkg explicitly.</p>
]]></content:encoded>
			<wfw:commentRss>http://mariusvw.com/2010/06/08/how-to-upgrade-perl-5-8-x-to-5-10-x-on-freebsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

