<?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>Projects Log &#187; perl</title>
	<atom:link href="http://dev.pulsed.net/wp/?cat=5&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://dev.pulsed.net/wp</link>
	<description>projects, diy</description>
	<lastBuildDate>Mon, 25 Jul 2011 11:22:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Microsoft Scripting Guys failed at Perl&#8230; big time</title>
		<link>http://dev.pulsed.net/wp/?p=36</link>
		<comments>http://dev.pulsed.net/wp/?p=36#comments</comments>
		<pubDate>Sat, 02 Feb 2008 18:42:08 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[scripting guys]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=36</guid>
		<description><![CDATA[So don&#039;t get me wrong, I&#039;m still a great MS fan and everything&#8230; but come on&#8230; they could have tested their script before publishing it!
the failure: (source microsoft.com)

click here for full page

That&#039;s the original url but I don&#039;t think that error will last long on that page
So, what&#039;s wrong, and what would be correct?
Let&#039;s take [...]]]></description>
			<content:encoded><![CDATA[<p>So don&#039;t get me wrong, I&#039;m still a great MS fan and everything&#8230; but come on&#8230; they could have tested their script before publishing it!</p>
<p><em>the failure: (source microsoft.com)</em></p>
<p><a href="http://dev.pulsed.net/misc/ms_failure_at_perl.png"><img src="http://dev.pulsed.net/misc/ms_failure_at_perl_sm.png" alt="!!FAILURE!!" /><br />
click here for full page</a></p>
<p><span id="more-36"></span><br />
<a href="http://www.microsoft.com/technet/scriptcenter/funzone/games/tips08/gtip0201.mspx#EZB">That&#039;s the original url but I don&#039;t think that error will last long on that page</a></p>
<p>So, what&#039;s wrong, and what would be correct?</p>
<p><strong>Let&#039;s take their code:</strong></p>
<p><code>$strValue = "ABCDE5FGHIJKLM";<br />
if ( $strValue == /[0-9]/ )<br />
    {print "This value contains a number. \n";}</code></p>
<p><strong>here&#039;s what you need to know to understand why it won&#039;t work:</strong></p>
<p>perl has an awesome variable ( $_ ) that is somehow the default input value</p>
<p><code>$str="Perl ";<br />
$_="rocks";<br />
print $str;<br />
print;</code></p>
<p>the first print will print $str like we want to, and the second one will print $_ because we didn&#039;t specify another variable.<br />
It works the same for regular expression, since == is not the correct operator to apply a regex on a string, it&#039;ll evaluate the $_ variable.</p>
<p>== is the equality operator that returns true if the left argument is <strong>numerically equal</strong> to the right argument.</p>
<p>So they are trying to compare the result of a regular expression that searches a number in an empty variable (remember $_), which obviously returns false, to a string using the numeric equality operator (I havn&#039;t told you that before, but obviously any string is seen as false for the == operator)<br />
<code>if(false == false)</code> => true, so even if there&#039;s no number in the $strValue variable, it&#039;ll say &#034;This value contains a number.&#034;</p>
<p><strong>So here&#039;s the code that actually works:</strong></p>
<p><code>$strValue = "ABCDE5FGHIJKLM";<br />
if ( $strValue =~ /[0-9]/ )<br />
    {print "This value contains a number. \n";}</code></p>
<p>=~ is NOT a comparison operator!<br />
Binary &#034;=~&#034; binds a scalar expression to a pattern match. (<a href="http://perldoc.perl.org/perlop.html">perlop</a>)<br />
that basically means that the regular expression  is applied to the variable that is on the left side of the =~ operator.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=36</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Patching Smokeping for Windows so you don&#039;t have to.</title>
		<link>http://dev.pulsed.net/wp/?p=31</link>
		<comments>http://dev.pulsed.net/wp/?p=31#comments</comments>
		<pubDate>Sun, 14 Oct 2007 16:49:48 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[smokeping]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=31</guid>
		<description><![CDATA[I&#039;m releasing this today, but it&#039;s still in beta (Everything that used to work with my old 2.0.8 patch works with that version, but not all new features have been tested yet)
What you&#039;ll need:
-Perl (latest version if you can)
-A web server (wamp is good, but others should work fine as well)

What the script will do [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;m releasing this today, but it&#039;s still in beta (Everything that used to work with my old 2.0.8 patch works with that version, but not all new features have been tested yet)</p>
<p><strong>What you&#039;ll need:</strong></p>
<p>-<a href="http://activestate.com/store/activeperl/">Perl</a> (latest version if you can)<br />
-A web server (<a href="http://www.wampserver.com/en/">wamp</a> is good, but others should work fine as well)</p>
<p><strong><br />
What the script will do and what it won&#039;t:</strong></p>
<p><strong>it will:</strong> download smokeping, rrdtool, and fping, help you configure smokeping (owner, mail, etc), patch what&#039;s needed to be patched, install a new feature that is not included in smokeping&#039;s official package (zoom in/out with pageup|pagedown)<br />
<strong>it won&#039;t:</strong> install/configure your webserver, install perl, add targets in your configuration file</p>
<p><strong><br />
what&#039;s working and what&#039;s untested yet:</strong></p>
<p><strong>working:</strong> everything that used to work with the 2.0.8 version, Ajax based ineractive graph zooming (+ my exclusive zoom with pageup/pagedown feature), Multi Target Graphs, using drives different than &quot;c:&quot;<br />
<strong>not tested yet:</strong> Master/Slave setup for multi source smokeping deployments.</p>
<p><strong>How to configure wamp, or apache:</strong><br />
<strong>edit</strong> httpd.conf (C:\wamp\Apache2\conf\httpd.conf with wamp)<br />
<strong>change: </strong>ScriptAlias /cgi-bin/ &quot;C:/wamp/Apache2/cgi-bin/&quot; into ScriptAlias /cgi-bin/ &quot;c:/wamp/cgi/&quot;    <strong>*</strong><br />
<strong>change: </strong>&lt;Directory &quot;C:/wamp/Apache2/cgi-bin/&quot;> into &lt;Directory &quot;c:/wamp/cgi&quot;>     <strong>*</strong><br />
(<strong>*</strong> you don&#039;t _have_ to do that, and of course you can change every paths, you just have to provide every paths to the install script)<br />
<strong>create</strong> a folder in your www root folder (c:\wamp\www if you&#039;re runing wamp) and name it &quot;simg&quot;</p>
<p>The install script will ask you the www root folder and the image folder</p>
<p><code>WWW root folder [Default: C:\wamp\www] (must already exist)</code></p>
<p><code>image folder from C:\wamp\www [Default: simg]</code></p>
<p>that&#039;s it! if something is not self explanatory enough, or if you have questions feel free to leave a comment</p>
<p>for testing, and autostart take a look at steps 7,8, and 10 here <a href="http://dev.pulsed.net/wp/?p=3">http://dev.pulsed.net/wp/?p=3</a></p>
<p><a href="http://dev.pulsed.net/misc/smokepinginstaller.zip">Download the Smokeping Installer for Windows</a>, unzip it and launch &#034;install n patch.pl&#034;</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=31</wfw:commentRss>
		<slash:comments>127</slash:comments>
		</item>
		<item>
		<title>Useless Dichotomic Morse to Human converter</title>
		<link>http://dev.pulsed.net/wp/?p=28</link>
		<comments>http://dev.pulsed.net/wp/?p=28#comments</comments>
		<pubDate>Fri, 17 Aug 2007 13:51:24 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[easy]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[useless]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=28</guid>
		<description><![CDATA[I&#039;m using the binary decision tree approach to convert Morse Code to &#034;Human&#034;

Here&#039;s a part of the tree (not complete)


Lets decipher &#034;â€” Â· â€”&#034;:
First mark is a dash -> next level and right node
Second mark is a dot -> next level and left node
Third mark is a dash -> next level and right node
&#034;â€” Â· [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;m using the binary decision tree approach to convert Morse Code to &#034;Human&#034;<br />
<br />
Here&#039;s a part of the tree (not complete)<br />
<img src="http://dev.pulsed.net/misc/dich2.png" alt="Binary Tree" /><br />
<br />
Lets decipher &#034;â€” Â· â€”&#034;:<br />
First mark is a dash -> next level and right node<br />
Second mark is a dot -> next level and left node<br />
Third mark is a dash -> next level and right node<br />
&#034;â€” Â· â€”&#034; = K</p>
<div style="border: 1px dashed #708090; background-color: #add8e6">
	<code>use strict;</code><br />
	<code></code><br />
	<code>my $index;</code><br />
	<code>while(&lt;&gt;)</code><br />
	<code>{</code><br />
	<code>chomp;</code><br />
	<code>for(split / +/)</code><br />
	<code>{</code><br />
	<code>$index=0;</code><br />
	<code>for(split //)</code><br />
	<code>{</code><br />
	<code></code><br />
	<code>{</code><br />
	<code>$index=($index+1)*2-1;</code><br />
	<code>}</code><br />
	<code></code><br />
	<code>{</code><br />
	<code>$index=($index+1)*2;</code><br />
	<code>}</code><br />
	<code>else</code><br />
	<code>{</code><br />
	<code>print &quot; &quot;;</code><br />
	<code>$index=0;</code><br />
	<code>}</code><br />
	<code>}</code><br />
	<code>print @morse_table[$index-1] if $index&gt;0;</code><br />
	<code>$index=0;</code><br />
	<code>}</code><br />
	<code>print $/;</code><br />
	<code>}</code>
</div>
<p>	<strong>Download this code:</strong> <a href="http://dev.pulsed.net/wp/code/morse.pls">morse.pls</a>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=28</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to get the MAC address of a remote computer with its IP address with perl</title>
		<link>http://dev.pulsed.net/wp/?p=18</link>
		<comments>http://dev.pulsed.net/wp/?p=18#comments</comments>
		<pubDate>Tue, 01 Aug 2006 16:59:48 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=18</guid>
		<description><![CDATA[Windows >= 2000 only (or maybe NT4.0 SP6)
This is the cool solution, or you could parse the result of `ping -n 1 $ip > nul &#038; arp -a` searching for $ip in the list (very slow and unpretty solution btw)
We will use two Windows dll ( iphlpapi.dll and wsock32.dll ) to import two functions ( [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Windows >= 2000 only (or maybe NT4.0 SP6)</strong></p>
<p>This is the cool solution, or you could parse the result of `ping -n 1 $ip > nul &#038; arp -a` searching for $ip in the list (very slow and unpretty solution btw)</p>
<p>We will use two Windows dll ( <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_helper_function_reference.asp">iphlpapi.dll</a> and <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_reference.asp">wsock32.dll</a> ) to import two functions ( <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/sendarp.asp">SendARP</a> and <a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/inet_addr_2.asp">inet_addr</a> );<br />
to do that, we will need <a target="_blank" href="http://search.cpan.org/~acalpini/Win32-API-0.41/API.pm">Win32::API perl module</a>.<br />
if you have some error like &#034;Can&#039;t locate Win32/API.pm in @INC&#8230;&#034; when you try to run the script, you need to install it:<br />
type: <em>ppm install Win32-API</em> in a dos prompt.</p>
<p><span id="more-18"></span></p>
<p><strong>What is <acronym title="Address Resolution Protocol ">ARP</acronym>?</strong></p>
<blockquote><p>Address Resolution Protocol (ARP) is a required TCP/IP standard defined in RFC 826, &#034;Address Resolution Protocol (ARP).&#034; ARP resolves IP addresses used by TCP/IP-based software to media access control addresses used by LAN hardware. ARP provides the following protocol services to hosts located on the same physical network:</p>
<li>Media access control addresses are obtained by using a network broadcast request in the form of the question &#034;What is the media access control address for a device that is configured with the enclosed IP address?&#034;</li>
<li>When an ARP request is answered, both the sender of the ARP reply and the original ARP requester record each other&#039;s IP address and media access control address as an entry in a local table called the ARP cache for future reference.</li>
</blockquote>
<p><a target="_blank" href="http://technet2.microsoft.com/WindowsServer/en/library/7b77bb1b-5c57-408f-907f-8b474203a5331033.mspx?mfr=true"><em>Source: microsoft.com</em></a></p>
<p>In other words, ARP is a protocol used to translate IP addresses to MAC (physical) addresses.</p>
<p><img src="http://dev.pulsed.net/misc/arp_ethereal.png" alt="Ethereal capture" /><br />
<em>As you can see, this looks pretty simple, one question (frame 1), and one answer (frame 2)</em></p>
<p>In order to improve performances, and to lower network charge, the data are cached locally.<br />
You can access (read/write) the ARP cache data with the arp command:<br />
for example: <strong>arp -a</strong> displays every ARP entries.<br />
You may need to ping the computer before.</p>
<p><img src="http://dev.pulsed.net/misc/arp_cmd.png" alt="arp -a" /></p>
<p>Well, the code now (192.168.0.254 is just an example):</p>
<p class="warning">[The requested file <kbd>http://dev.pulsed.net/wp/code/arp.pl</kbd> could not be found]</p>
<p>The best part of this little script is (what i thought impossible in perl) the dll function import!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=18</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to delete file older than X days with Perl and WMI</title>
		<link>http://dev.pulsed.net/wp/?p=8</link>
		<comments>http://dev.pulsed.net/wp/?p=8#comments</comments>
		<pubDate>Sun, 09 Jul 2006 16:23:26 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[win32]]></category>
		<category><![CDATA[wmi]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=8</guid>
		<description><![CDATA[Original idea: Microsoft Scripting Guys (link)
Ok, that&#039;s not that hard, some VBScript to Perl translation, a little modification and that&#039;s all!
I think it should work works remotely too (untested yet) by changing $strComputer with the targeted computer (you need some specific credentials).

my $strComputer = &#034;.&#034;;
&#034;.&#034; means local computer
my $maxage=15;
every file older than 15 days in [...]]]></description>
			<content:encoded><![CDATA[<p>Original idea: Microsoft Scripting Guys (<a target="_blank" href="http://www.microsoft.com/technet/scriptcenter/resources/begin/ss0706.mspx">link</a>)</p>
<p>Ok, that&#039;s not that hard, some VBScript to Perl translation, a little modification and that&#039;s all!</p>
<p><strike>I think</strike> it <strike>should work</strike> works remotely too <strike>(untested yet)</strike> by changing $strComputer with the targeted computer (you need some specific credentials).<br />
<span id="more-8"></span><br />
<em>my $strComputer = &#034;.&#034;;</em><br />
&#034;.&#034; means local computer</p>
<p><em>my $maxage=15;</em><br />
every file older than 15 days in $folder will be deleted</p>
<p>my $folder=&#034;c:\\temp&#034;;<br />
change this with the folder you want to check (<strong>WARNING: be careful</strong> to prevent unwanted file from being deleted, and do not forget to escape \ character everywhere)</p>
<p style="font-family: monospace; color: rgb(255, 0, 0);">[edited: July 10, 2006 &nbsp;11:00 pm =&gt; scan subfolders recursively;<br />uncomment #$_->Delete; after some tests to realy delete files]</p>
<p class="warning">[The requested file <kbd>http://dev.pulsed.net/wp/code/delete.pl</kbd> could not be found]</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=8</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Find your printers with Active Directory and Perl</title>
		<link>http://dev.pulsed.net/wp/?p=7</link>
		<comments>http://dev.pulsed.net/wp/?p=7#comments</comments>
		<pubDate>Thu, 06 Jul 2006 09:14:30 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[Active directory]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=7</guid>
		<description><![CDATA[Small perl script to find every printer in the active directory with perl

[The requested file http://dev.pulsed.net/wp/code/find_printers_with_AD_and_perl.pl could not be found]
]]></description>
			<content:encoded><![CDATA[<p>Small perl script to find every printer in the active directory with perl</p>
<p><span id="more-7"></span></p>
<p class="warning">[The requested file <kbd>http://dev.pulsed.net/wp/code/find_printers_with_AD_and_perl.pl</kbd> could not be found]</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=7</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>List locked accounts in a container or an OU using Perl</title>
		<link>http://dev.pulsed.net/wp/?p=4</link>
		<comments>http://dev.pulsed.net/wp/?p=4#comments</comments>
		<pubDate>Mon, 26 Jun 2006 16:05:43 +0000</pubDate>
		<dc:creator>Kevin DEHLINGER</dc:creator>
				<category><![CDATA[Active directory]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://dev.pulsed.net/wp/?p=4</guid>
		<description><![CDATA[Again, perl is a great language which could help you to save a lot of time (administration scripts, &#8230;)
Here&#039;s a perl script to list every locked accounts in a container or an OU!

[The requested file http://dev.pulsed.net/wp/code/locked_accounts.pl could not be found]
]]></description>
			<content:encoded><![CDATA[<p>Again, perl is a great language which could help you to save a lot of time (administration scripts, &#8230;)</p>
<p>Here&#039;s a perl script to list every locked accounts in a container or an OU!</p>
<p><span id="more-4"></span></p>
<p class="warning">[The requested file <kbd>http://dev.pulsed.net/wp/code/locked_accounts.pl</kbd> could not be found]</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.pulsed.net/wp/?feed=rss2&amp;p=4</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
