perlmeditation
Bloodrage
<p>Ave sodales ab camelus</p>
<p>I like <a href="http://www.ultraedit.com">UltraEdit32</a><sup>1</sup> it's nice. I like it for hacking about with Perl, ECMAScript<sup>2</sup>, XML, CSS, and XHTML... and I suppose plain text too. At the same time as purchasing it, I wanted to be able to continue my hackery at work (where I don't have install privilages) so I thought about running it off a flash drive... then I saw <a href="http://www.ultraedit.com/products/ue3.html">this</a>. I pondered this briefly and purchased the UltraEdit/UE3 bundle, and a <a href="http://www.sandisk.com/Products/Item(1925)-SDCZ6-4096-A10-SanDisk_Cruzer_Micro_4GB_Black.aspx">4GB U3 flash drive</a> (and a 2BG U3 Flash drive to bribe Her, which she likes very much). This works very very well.
<p>Shortly afterwards I found <a href="http://u3.desiblogs.co.uk/tag/command-prompt-portable/">Command Prompt Portable U3</a> and it occured to me "If I can fire up a command prompt off my flash drive, can I make Perl run off it too? Then I'd have a Perl dev-suite in my pocket. That would be cool."</p>
<p>The plan was simple;</p>
<ol>
<li>Install Command Prompt Portable U3 onto my stick, and run it once to finalise the installation.</li>
<li>Do a fresh <a href="http://win32.perl.org/wiki/index.php?title=Strawberry_Perl">Strawberry Perl</a><sup>3</sup> install (download from <a href="http://www.strawberryperl.com">here</a>)</li>
<li>Copy the installation to the flash drive</li>
<li>Edit the environment variables set in <code>commandprompt.bat</code> to include the new Perl directory, before any existing paths. Something like this:<readmore><code>
echo Setting Path to Strawberry Perl
set STRAWBERRY=%U3_DEVICE_PATH%\strawberry
path %STRAWBERRY%\c\bin;%STRAWBERRY%\perl\bin;%PATH%
set LIB=%STRAWBERRY%\c\lib;%STRAWBERRY%\perl\bin;%LIB%
set INCLUDE=%STRAWBERRY%\c\include;%STRAWBERRY%\perl\lib\CORE;%INCLUDE%
set PKG_CONFIG_PATH=%STRAWBERRY%\lib\pkgconfig
</code></readmore></li>
<li>Bingo! Portable command prompt with Perl</li>
</ol></p>
<p>Actually it was as simple as that. Perl mostly worked.</p>
<p>What didn't work was installing things with CPAN... especially things that needed C++ complied. The first bit was fixed with a Perl program that was run on opening the command prompt (see this meditation on <a href="http://www.perlmonks.org/?node_id=669488">Changing Perl Config settings</a>). This also partially solved the compiling problem (to some degree, still can't compile <code>GTK2-perl</code><sup>4</sup>), but I'll probably meditate on that in another thread.</p>
<p>Following the instructions [randyk] has given <a href="http://www.perlmonks.org/?node_id=659553">here</a> adds [mod://PPM], [mod://XML::Parser], <code>eXpat</code> and <code>SOAP</code> to the Strawberry Perl installation, giving my stick working PPM installs, and this line <code>ppm set build %STRAWBERRY%\ppm</code> is added to <code>commandprompt.bat</code><sup>5</sup> to set up a working directory for PPM (you may have to create it manually first).
<p>So far it's been working very well (except for C++ compiling) and I prefer it now to my own computer's installation of Perl (ActiveState 64bit actually). I have noted the following issues:</p>
<ul>
<li>Windows sometimes randomly chooses to recognise file ownership or something and won't let the script update the config files. Restore the originals and restart the command prompt and it works again.</li>
<li><code>cpan</code> sometimes leaves it's lockfile locked and can't reset it. Delete it and try again and it's fine.</li>
<li>Any CPAN configurations in your <code>C:\Documents and Settings\Username\Local Settings\Application Data\.cpan</code> will override the settings elsewhere, including your stick. Delete that too...</li>
<li>Using <code>o conf</code> in CPAN will often make the config file unreadable/unwritable to the script. Delete it, restore backup...</li>
<li>Using CPAN's autoconfig can be unpredictable. If it shows up the script failed. Fix whatever caused that first. ...you might also consider restoring those backups too...</li>
<li>Flattening the include libraries doesn't help with the compiling. Mostly it seems to be Makefile or Makefile.PL that have shell components that fail... or more likely dependencies I don't have. At least you don't have to restore the backed up config files.</li>
</ul>
<p>This tells me I need to make a roll-back script that restores those <code>config.pm.orig</code> files I carefully backed up and removes the cpan lock file, and I need to carefully put together my compile libraries.</p>
<p>Do any other Perl Monks have any further suggestions or comments for this project?</p>
<strong>Updated:</strong>Incorporated material from comments.
<hr>
<p><sup>1</sup><small>Damn. I just noticed that the new version is out. With added nifty, like useing regexes to do search and replace within your documents. Sigh, so many features to ignore...</small></p>
<p><sup>2</sup><small>I despise the JavaScript misnomer. Stop it. You too can help stamp out confusion.</small></p>
<p><sup>3</sup><small>I chose Strawberry Perl because it includes minGW (a compiler) and a significant subset of the GNU libraries already compiled for Windows. I suspect ActivePerl will also work.</small></p>
<p><sup>4</sup><small>I want to do graphics, I've chosen the GTK2 library because it's fairly straight forward, it utilises <a href="http://cairographics.org/">Cairo</a>, it can also render to image files and SVG, and it would make my programs simpler to implement in other operating systems. Using <a href="http://search.cpan.org/dist/Win32-GUI/"><code>Win32::GUI</code></a> would tie my work to Windows.</small></p>
<p><sup>5</sup><small>as noted <a href="http://www.perlmonks.org/?node_id=659597">here</a> by [syphilis]</small></p>
<p><small><strong>PS</strong> Semi-final rewrite. Will probably add some more to it later.</small></p>
<p><small>If all else fails the Command Prompt U3 can be found on <a href="http://rapidshare.com/files/76620904/Command_Prompt.u3p">RapidShare</a> too.</p>