Modern Perl 2011-2012 Drafted
For all you fellow Perl lovers, Chromatic has posted an update to the old Modern Perl book. Get the 2011-2012 version there.
I haven’t read the new version yet, but have dropped it onto my tablet for those times when stuck waiting someplace. It should be considered alpha, so expect typos at this point. Read it for the ideas, not to copy/paste code.
Perl Dancer WebApp Framework
If you would like to use a really solid, web-app creation, perl module, I can completely recommend Perl Dancer. Wrote a little server a few months ago and it has been running non-stop without issues all this time. It makes the simple things trivial and … well, I’ve only done simple things so far. ;) That entire app (including the DBIx backend) is only 350 lines of code. Modern Perl rocks.
Git DVCS Server Setup and Use in a Team
It seems that all the software developers are using git DVCS these days. I haven’t done serious software development in many years, so I’ve been using RCS all this time for my system admin scripting needs. With my new development work, I need to upgrade my toolset to a DVCS – Distributed Version Control System. There are many reasons to do this even if you don’t want to publish all your code on the internet. Below I’ll show how to setup an internal git server that can be shared inside a company or just between friends on the internet.
I’ll assume:
- Your git server will be on a Linux/Unix system someplace where
- all the developers will have ssh connection access.
- You have git installed on the server and the clients already.
Those server connections may allow full shell access or be limited to support just git. Regardless, setting up ssh-keys – Ssh Config Setup – is a good idea between the client(s) and the server computers.
Keep reading to learn about Git setup.
Perlbrew for Self-Contained Perl Installations 1
For years scripting languages like perl and add-ons like perl modules were supposed to be installed as part of the OS. This worked when the server administrator was the primary programmer on the system who could control all that stuff. In these days of role-based administration, the users and the administrators are hardly ever the same person. Administrators have different needs for systems than users or programmers and often those needs conflict.
How do we solve this problem for Perl scripts? Perlbrew.
Perl CPAN Made Easy
CPAN, the Comprehensive Perl Archive Network, contains 10,000+ different Perl modules. All of these work just about the same to get installed on a system. That’s because Perl programmers use a standard package for distributing software that includes the code, tests, and manual. Below I’ll show the general way to build and install most perl modules, including those with external, non-perl, dependencies. Then I’ll show how to automate this with CPAN.
Subtitle Script for I to l Converstions
A quick script to change a capital I (eye) in the middle of a word into a lowercase l (el). If you like Asian films, you understand why I wrote this script. I had an itch. It needed to be scratched. This is useful for .srt files used in movie subtites.
#!/usr/bin/perl # Perl script to change every 'I' into an 'l' in the middle of a word # input is stdin and output is to stdout; redirection is your friend my $line; while(<>){ chomp; $line=$_; $_=$line; # Match lines with non-whitespace characters leading a capital I if ( m/[\S]I/ ){ $line =~ tr/I/l/; } print "$line\n"; }
It is very common for subtitle files, SRT format, to have a capital I in the middle of words since bitmap patterns are used to create the files. For native speakers of English, this is HIGHLY distracting – to the point that the subtitles must be fixed before a movie can be enjoyed.
I tried a few other methods, before determining this simple character translation was needed.
- ispell – There were too many words that were not in the dictionary and spacing of words often groups them in strange ways.
- replacement dictionary – I created a hundred word dictionary replacement sed script. There were always new words that needed to be added for every SRT file.
- Manual editing – yep, I spent a few hours manually editing files. This wasn’t very efficient and ruined the movie plot since I’d already read it before viewing it.
Some combination of methods will probably be necessary. I intend to merge them into a single perl script and perform them in the most efficient order. It will begin with the I—>l translation.
Geany A Lightweight IDE and Code Editor
Part of me has wished I had a fancy IDE like visual studio provides, but without the commercial license and heavy system resources. I usually find vim to be enough syntax highlighting and it is definitely light weight. Occasionally, jEdit or Notepad++ seems like the best compromise between small, fast and features.
This morning I found Geany. It feels like emacs without the memory requirements. It has tabbed files and function indexes. The view for each function or code block can be compressed/hidden easily.
Best of all, it doesn’t depend on either Gnome or KDE toolkits, so it doesn’t force specific desktop environment libraries to be loaded, reducing RAM requirements for half of us that use the othe OE.
I hope my fellow Linux users find this code editor – mini-IDE useful.
What's Wrong with Perl 1
Perl is a “C” like scripting language for those of you who didn’t immediately know or thought I misspelled pearl.