Home » 2010 » August

Use File::Find for recursive directory searches


Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /var/www/blog_htbaa_com/www/wp-content/plugins/source-code-syntax-highlighting-plugin-for-wordpress/geshi.php on line 2136

One of the finest Perl (core!) module I’ve been using lately is File::Find. With File::Find it’s possible to traverse through a directory recursively to find anything you want from it. It comes with a number of options to alter the search behavior and a custom callback has to be supplied to determine what to do with the found file. Such as adding it to a list if it meets certain criteria, computing MD5 checksums or whatever else floats your boat.

Here’s a small example I also posted some time ago on Stack Overflow.

  1. span class=”st0″>’.’‘..’‘/my/dir/to/search’

Using Perl-Tidy with Notepad++

I was looking for a way to use Perl::Tidy with Notepad++ so I can format my Perl code from within Notepad++. Luckily for me someone else already figured out how to do this properly. I just had to modify a few small things to make this work for my needs.

My environment is a Windows Vista SP2 system with Strawberry Perl 5.12.1. Thanks to Strawberry modifying the system PATH I don’t need to configure this myself. After installing Perl::Tidy I can just call the perltidy command from the command-line. But for some reason calling the perltidy directly from within NppExec doesn’t work.

First, you need a .perltidyrc, or rather on Windows a perltidy.ini. I don’t really know why this has to be different, probably because it sometimes can be a pain to create a nameless file (meaning, a file with only a extension). Here’s my perltidy.ini file which I installed under C:\Users\<USERNAME>\perltidy.ini. I’ve actually shamelessly stolen this configuration from Mojo.

So following the earlier mentioned blog post this is what I changed to make it work for me.

  1. Change the command-line in NppExec to the following:
    perl -x -S perltidy "$(FULL_CURRENT_PATH)"
  2. Do the Advanced Options part
  3. Now create a Macro: for some reason this doesn’t work?

    1. Start recording
    2. Go to Macro > Execute your newly added perltidy macro
    3. Go to File > Reload from Disk
    4. Stop recording
    5. Save Macro and assign a shortcut to it

Now I wanted to be able to fire this off with a key shortcut, but I can’t add those to macro’s created with NppExec. So instead I tried to create a macro that executes the perltidy macro and then reloads the file from disk. But when executing this macro nothing happens. So if anyone has an idea to why this is I’d be glad to hear it.

For now this manual execution will work just fine. It’s just annoying that I’ll have to reload the file from disk manually.

Not on internet equals to being death?

Almost everyone in their twenties has an existence on the Internet. It’s basically expected you can be found online. So, what I was wondering: can I consider someone of my age, which is to be expected to have some online profile, be dead if nothing can be found online?

If intentional I applaud them for it, as it’s almost impossible to stay anonymous. Every website requires you to sign-up of the personal details are eventually sold to someone else. Since a lot of jobs require you to use a computer and Internet it’s almost impossible to stay anonymous.

Or am I just looking in the wrong direction?

Finished reading: The Definitive Guide to Catalyst

A couple of days ago I finished reading The Definitive Guide to Catalyst which for a technical book (or any at all) I read through quite fast. I’m not going to write a full fledged review about it but I can recommend it to anyone interested in working with Catalyst. For those who don’t know it Catalyst is a web application framework written in Perl.

Although the online documentation is very good the book is a nice addition to it. It’s more than just a collection of some code examples. The chapters follow a certain thought process to write maintainable and extensible code, complete with tests and all. Common in the book is that the example code will get a rewrite later on in the chapter to reach this goal. I consider this a nice feature of the book as it shows why that refactoring was needed and is the better solution to the problem.

There are only a few small complaints I’ve got about the book. The code indentation isn’t always consistent and there are occasionally some errors in the code. But looking more at it from a conceptual kind of view it’s clear what the author intents. I also don’t really understand the choice to include Reaction in the final chapter. Documentation is scarce and it seems abandoned. I’d much rather see some Catalyst::Runtime core modules described in there, such as Catalyst::ScriptRunner (did it even exist at the time of writing?), Catalyst::Request and Catalyst::Response. I know the latter 2 are well documented, but they weren’t even mentioned in the book.

Other than that it was a great read and am glad I bought it :-).

A month has passed since moving to Rackspace Cloud Servers

A month has passed since I’ve moved to a Cloud Server from Rackspace and so far I’m pleased with the whole experience.

It did take a bit of tweaking before I got everything working the way I wanted. This mostly consisted of properly configuring PHP FastCGI as it’s a big resource eater. Another help was making sure that lighttpd is adding proper ETag’s and expire headers. On the WordPress side I was able to configure the WP-SuperCache which takes away some page generation overhead as well.

For the time being I’ll let Rackspace provide me a Cloud Server. I don’t generate that much traffic yet to convince myself to move to Linode, which has bigger VPS servers (more RAM, traffic and storage) for better prices.