<?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>mincus code &#187; Perl</title>
	<atom:link href="http://code.mincus.com/category/perl/feed/" rel="self" type="application/rss+xml" />
	<link>http://code.mincus.com</link>
	<description></description>
	<lastBuildDate>Tue, 29 Dec 2009 20:00:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Combine Multiple MP3 Files without Special Software</title>
		<link>http://code.mincus.com/48/combine-multiple-mp3-files-without-special-software/</link>
		<comments>http://code.mincus.com/48/combine-multiple-mp3-files-without-special-software/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 20:00:50 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://code.mincus.com/?p=48</guid>
		<description><![CDATA[Just found out that you do not need any special software to join multiple MP3 files together. I&#8217;m sure that this is an old trick, but wanted to save it here as so I will be less likely to forget it. In Windows: copy /b File1.mp3 + File2.mp3 + FileX.mp3 NewFile.mp3 In Linux: cat File1.mp3 [...]]]></description>
			<content:encoded><![CDATA[<p>Just found out that you do not need any special software to join multiple MP3 files together.  I&#8217;m sure that this is an old trick, but wanted to save it here as so I will be less likely to forget it.</p>
<p>In Windows:</p>
<pre>copy /b File1.mp3 + File2.mp3 + FileX.mp3 NewFile.mp3</pre>
<p>In Linux:</p>
<pre>cat File1.mp3 File2.mp3 > NewFile.mp3</pre>
<p>For both methods, you can also use wildcards instead of explicitly naming each file.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/48/combine-multiple-mp3-files-without-special-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Win32::OLE Excel Selection + TextToColumns</title>
		<link>http://code.mincus.com/42/perl-win32ole-excel-selection-texttocolumns/</link>
		<comments>http://code.mincus.com/42/perl-win32ole-excel-selection-texttocolumns/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 14:02:39 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://code.mincus.com/?p=42</guid>
		<description><![CDATA[Finally figured out how Excel Selection + TextToColumns translates from VB to Perl using the module Win32::OLE One of those things that I&#8217;m sure millions of have done, but I never saw an exact example before so I never could get it to work before. One other thing that has been a huge help: Excel [...]]]></description>
			<content:encoded><![CDATA[<p>Finally figured out how Excel Selection + TextToColumns translates from VB to Perl using the module <a href="http://search.cpan.org/~jdb/Win32-OLE/">Win32::OLE</a></p>
<p>One of those things that I&#8217;m sure millions of have done, but I never saw an exact example before so I never could get it to work before.</p>
<p>One other thing that has been a huge help: <a href="http://www.datapigtechnologies.com/downloads/Excel_Enumerations.txt">Excel Constant Enumerations</a></p>
<p>Hopefully these will save someone else some hassle, good luck!</p>
<pre>
#!c:/perl/bin/perl.exe

use strict;
use warnings;
use Win32::OLE;

my $excel        = Win32::OLE->new( 'Excel.Application' )
  or die "Could Not Start Excel.\n";
$excel->{ 'Visible' }           = 1;
$excel->{ DisplayAlerts }       = 0;
$excel->{ SheetsInNewWorkBook } = 1;

my $workbook = $excel->Workbooks->Add();
my $sheet = $workbook->Worksheets( 1 );
$sheet->{ 'Name' } = 'Approved Vs Denied';
$sheet->Activate;
$sheet->Range( "A1" )->{ Value } = '"1","2","3"';
$sheet->Range( "A2" )->{ Value } = '"4","5","6"';

$sheet->Range( "A1:A2" )->Select(); # Make your cell selections
$excel->Selection->TextToColumns( {  #But then reference the selection using the Excel Object
        Destination          => $sheet->Range( "A1" ), # Where to put the top left corner of the text-to-columns
        DataType             => 1,                        # Fixed ( 2 ) // Delimited ( 1 )
        TextQualifier        => 1,                        # DoubleQuote ( 1 ) // None (-4142) // SingleQuote( 2 )
        ConsecutiveDelimiter => 0,                        # (True or False)
        Tab                  => 0,                        # (True or False)
        Semicolon            => 0,                        # (True or False)
        Comma                => 1,                        # (True or False)
        Space                => 0,                        # (True or False)
        Other                => 0,                        # (True or False)
        FieldInfo            => [ [1,1], [2,1], [3,1] ],  #Array Ref of array refs with num of Columns + Type of each column
        TrailingMinusNumbers => 1,                        # (True or False)
} );
</pre>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/42/perl-win32ole-excel-selection-texttocolumns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Tools Do You Use for Windows Automation?</title>
		<link>http://code.mincus.com/32/what-tools-do-you-use-for-windows-automation/</link>
		<comments>http://code.mincus.com/32/what-tools-do-you-use-for-windows-automation/#comments</comments>
		<pubDate>Thu, 02 Nov 2006 11:30:47 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://code.mincus.com/32/what-tools-do-you-use-for-windows-automation/</guid>
		<description><![CDATA[If you do any work in an IT support role, knowing how to use at least of one of the following tools is a requirement. The amount of repetitive work done in tasks like imaging or testing begs for automation and these tools can get the job done easily. Perl has been a must have [...]]]></description>
			<content:encoded><![CDATA[<p>If you do any work in an IT support role, knowing how to use at least of one of the following tools is a requirement.  The amount of repetitive work done in tasks like imaging or testing begs for automation and these tools can get the job done easily.<br />
<span id="more-32"></span></p>
<ul>
<li><a href="http://www.activestate.com/Products/ActivePerl/">Perl</a> has been a must have tool for systems administrators for almost two decades now.  Perl&#8217;s way of making the easy things easy and the difficult possible, its use for systems administration, network programming, and the vast library of code available from <a href="http://www.cpan.org">CPAN</a> make it a top choice for prototyping, interfacing with other applications, data munging, and automating.</li>
<li><a href="http://www.kixtart.org">Kixtart</a> is free tool that was designed internally at Microsoft Netherlands as a skunkworks project mainly intended for login scripts, but has been greatly expanded.  Interacting with AD, WMI, and the registry is extremely easy with kix.  Additionally, it has a great user base that has created hundreds of &#8220;functions&#8221; that can do almost anything that you need to do.</li>
<li><a href="http://www.autoitscript.com/autoit3/">AutoIT</a> shares many of the same benefits of kix, but makes automating simulated keystrokes, mouse movement, and window/control manipulation very easy.  Using AutoIT in a testing environment, for imaging, or for creating distributable executables makes this a very valuable tool.</li>
</ul>
<p>What tools do you use for Automation?</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/32/what-tools-do-you-use-for-windows-automation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Permalink Redirects</title>
		<link>http://code.mincus.com/29/wordpress-permalink-redirects/</link>
		<comments>http://code.mincus.com/29/wordpress-permalink-redirects/#comments</comments>
		<pubDate>Wed, 31 May 2006 13:57:36 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://code.mincus.com/29/wordpress-permalink-redirects/</guid>
		<description><![CDATA[The default WordPress URLs aren&#8217;t very search engine unfriendly &#8211; http://code.mincus.com/?p=3 Under the WordPress options, it is easy to change this to something much nicer looking, for example: http://code.mincus.com/3/adsense-notifier &#8211; But that could lead to losing the PR that you&#8217;ve built up from the old links if you make the change after your blog is [...]]]></description>
			<content:encoded><![CDATA[<p>The default WordPress URLs aren&#8217;t very search engine unfriendly &#8211; http://code.mincus.com/?p=3</p>
<p>Under the WordPress options, it is easy to change this to something much nicer looking, for example: http://code.mincus.com/3/adsense-notifier &#8211; But that could lead to losing the PR that you&#8217;ve built up from the old links if you make the change after your blog is established or <a href="http://www.wolf-howl.com/seo/duplicate-content-wordpress-blog/">duplicate content issues</a>.</p>
<p>For people using Apache, it should be relatively easy to add 301 permanent redirects using rewrite maps to fix both of these issues.<br />
<span id="more-29"></span></p>
<p>Three changes are needed to implement this:</p>
<ul>
<li>Add a rewrite map program</li>
<li>Tell Apache to use the rewrite map</li>
<li>Update your .htaccess to use the rewrite map</li>
</ul>
<p>Put this file somewhere where apache has access to execute it and name it something like mod_rewrite_map.pl.  Update the three variables with your own settings for the DB name, username, and password.  Make sure you give it execute permissions.  This program will run in the background and give the pretty URL name when passed an article ID.  Test it by running it then typing in an article ID and hitting enter.  If a friendly URL name comes back, you&#8217;ve got it working right.</p>
<pre>#!/usr/bin/perl
use DBI;

$|=1;

my $db_user = "database username";
my $db_pass = "database password";
my $db_name = "database name";

{
    my $DBH;
    my $STH;

    sub startdb {
        if ( !$DBH ) {
            $DBH = DBI->connect( 'DBI:mysql:' . $db_name, $db_user, $db_pass );
            my $query = 'select post_name from wp_posts where ID=?;';
            $STH = $DBH->prepare( $query );
        }
    }

    sub stopdb {
        if ( $DBH ) {
            $DBH->disconnect;
        }
        undef( $DBH );
    }

    sub execute_db {
        my $post_num = shift;
        my $post_name = '';

        startdb();

        $STH->execute( $post_num );
        $STH->bind_columns( \$post_name );
        $STH->fetch;
        return( $post_name );
    }
}

while(&lt;stdin&gt;) {
    chomp;
    print execute_db( $_ ) . "\n";
}

stopdb();</pre>
<p>Next, add the following lines to your httpd.conf.  They tell apache to load the rewrite map program into memory and when to use it.  While you can place these in a virtualhost, they are not virtualhost specific.  I just put them there in my httpd.conf because it makes it easier for me to remember my logic in setting it up.</p>
<pre>RewriteEngine On
RewriteMap name_recmap prg:/path/to/mod_rewrite_map.pl</pre>
<p>Last, add the following lines to your WordPress .htaccess &#8211; They tell apache to use your rewrite map and when.  In this setup it does the following:<br />
^p=([0-9]+)$ &#8211; If the query string is requesting a page, and is only digits<br />
rewrite the URL to be ID/Pretty-URL-Name/</p>
<pre>RewriteCond %{QUERY_STRING} ^p=([0-9]+)$
RewriteRule ^.*$ %1/${name_recmap:%1}/? [R=301,NC,L]</pre>
<p>That’s how I have it setup here on code.mincus right now.  But I recently found this <a href="http://fucoder.com/code/permalink-redirect/">Redirect WordPress plug-in</a> that seems like it will do all of this and more only easier.  If anyone gives it a try let me know how it works out.</p>
<p>UPDATE(10/19/2006):  I have been using Scott Yang&#8217;s <a href="http://fucoder.com/code/permalink-redirect/">Permalink Redirect WordPress plug-in</a> for a few months now and love it.  It&#8217;s a must have plug-in if you are using WordPress and have even a passing interest in SEO and rankings.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/29/wordpress-permalink-redirects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WSUS Remote Sync</title>
		<link>http://code.mincus.com/6/wsus-remote-sync/</link>
		<comments>http://code.mincus.com/6/wsus-remote-sync/#comments</comments>
		<pubDate>Tue, 29 Nov 2005 19:01:48 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://code.mincus.com/?p=6</guid>
		<description><![CDATA[WSUS Remote Sync is a tool which allows administrators to synchronize remote WSUS servers from the master console. The downloaded file (wsus_remote.exe 1.74mb, version 0.1) is an install program that also includes the source and readme files. After the install, be sure to edit the remote_conf.ini file to fill out the required information. As this [...]]]></description>
			<content:encoded><![CDATA[<p>WSUS Remote Sync is a tool which allows administrators to synchronize remote WSUS servers from the master console.<br />
<span id="more-6"></span><br />
The downloaded file (<a href="http://www.wsuswiki.com/files/WSUSRemoteSync/wsus_remote.exe">wsus_remote.exe</a> 1.74mb, version 0.1) is an install program that also includes the source and readme files.</p>
<p>After the install, be sure to edit the remote_conf.ini file to fill out the required information.</p>
<p>As this is an early release, there are many changes that I would like to make and look forward to hearing your feedback.  You can reach me at mincus \@ \gmail \.com</p>
<p>The program is licensed as open source under the GPL license, so feel free to modify the program as you may need.  Please also let me know of your changes so that I can incorporate them into the main tree.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/6/wsus-remote-sync/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>crontab -r</title>
		<link>http://code.mincus.com/5/crontab-r/</link>
		<comments>http://code.mincus.com/5/crontab-r/#comments</comments>
		<pubDate>Thu, 21 Apr 2005 02:55:21 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://code.mincus.com/?p=5</guid>
		<description><![CDATA[I understand the idea behind using &#8216;e&#8217; (edit) and &#8216;r&#8217; (remove) for crontab. But the problem with that is the &#8216;e&#8217; is dangerously close to the &#8216;r&#8217;. After accidentally deleting my cron file for the 80th time, I put together this quick Perl script that adds two features to crontab. The first feature is to [...]]]></description>
			<content:encoded><![CDATA[<p>I understand the idea behind using &#8216;e&#8217; (edit) and &#8216;r&#8217; (remove) for crontab.  But the problem with that is the &#8216;e&#8217; is dangerously close to the &#8216;r&#8217;.  After accidentally deleting my cron file for the 80th time, I put together this quick Perl script that adds two features to crontab.</p>
<p>The first feature is to prompt the user when the remove option is used and the second option is &#8211;force, which when combined with -r mimics the old crontab operation.</p>
<p>Maybe I just have clumsy fingers, but this script has saved me multiple times and eased my worry over accidentally deleting the crontab.<br />
<span id="more-5"></span><br />
The use this script, do the following -<br />
<strong>1)</strong> Create <code>/usr/local/scripts/safe_crontab.pl</code> with the following text:</p>
<pre>#!/usr/bin/perl -w
use strict;

my $run_crontab = 1;
my @safe_argv;
my ( $bForce, $bRemove, $bHelp );

foreach ( @ARGV ) {
    if ( uc( $_ ) eq '--FORCE' ) {
        $bForce = 1;
    } else {
        if ( uc( $_ ) eq '-R' ) {
            $bRemove = 1;
        }
        push( @safe_argv, $_ );
    }
}

if ( $bRemove ) {
    unless( $bForce ) {
        my ( $y_or_n );
        do {
            print 'Are you sure you want to remove the crontab? (Y/N): ';
            $y_or_n = uc( getc() );
            print "\n";
        } until ( ( $y_or_n eq 'Y' ) || ( $y_or_n  eq 'N' ) );
        if ( $y_or_n eq 'N' ) {
            print "/usr/bin/crontab: no changes made to crontab\n";
            $run_crontab = 0;
        }
    }
}

if ( $run_crontab ) {
    if ( system( '/usr/bin/crontab', @safe_argv ) == 256 ) {
        print "\t--force (delete crontab without prompting)\n";
    }
}</pre>
<p><strong>2)</strong> Add this line to <code>/etc/bashrc</code><br />
<code>alias crontab='/usr/local/scripts/safe_crontab.pl'</code></p>
<p><strong>3)</strong> Run the following command:<br />
<code>chmod 755 /usr/local/scripts/safe_crontab.pl</code></p>
<p><strong>4)</strong> Log off and back on and you should be all set.  Hope you find this useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/5/crontab-r/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Mail::Webmail::Gmail</title>
		<link>http://code.mincus.com/2/mail-webmail-gmail/</link>
		<comments>http://code.mincus.com/2/mail-webmail-gmail/#comments</comments>
		<pubDate>Sun, 10 Apr 2005 22:45:28 +0000</pubDate>
		<dc:creator>mincus</dc:creator>
				<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://code.mincus.com/?p=2</guid>
		<description><![CDATA[Available on cpan &#8211; Mail::Webmail::Gmail This module gives the ability to do almost anything with Gmail programmatically through perl. Thanks for all the hardwork and effort in getting this back up and working! I&#8217;ve been swamped and havent been able to do some maintenance on this module in a bit. Hopefully I will be able [...]]]></description>
			<content:encoded><![CDATA[<p>Available on cpan &#8211; <a href="http://search.cpan.org/~mincus/Mail-Webmail-Gmail/">Mail::Webmail::Gmail</a></p>
<p>This module gives the ability to do almost anything with Gmail programmatically through perl.<br />
<span id="more-2"></span><br />
Thanks for all the hardwork and effort in getting this back up and working!  I&#8217;ve been swamped and havent been able to do some maintenance on this module in a bit.  Hopefully I will be able to incorporate these change into the main tree soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://code.mincus.com/2/mail-webmail-gmail/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>
