banner
Dave Horner's Website - Yet another perspective on things...
Home Tech Talk Programming PERL Programming
If you appreciate the information found on this website, please drop me a line!

Who's Online

We have 37 guests online
Content View Hits : 1221409
moon and stars
How did you find my site?
 
How often do you answer random online questions?
 

Random Quote

"For every complex problem, there is a solution that is simple, neat, and wrong."
-- H.L. Mencken
DSC00568
wanger_family1
P1010016_001
P1010217

PERL Programming

Wednesday, 04 May 2005 18:20
I wouldn't say that PERL is my first and favorite language, but I would say that I have grown to appreciate it. I find that everyone has a different style when writing code in it. It is powerful with a lot of available CPAN modules, this makes development bit easier. I've seen some pretty amazing scripts...and some pretty unreadable perl code. So it goes.
The Perl motto TMTOWTDI, "There's More Than One Way To Do It" ,pronounced "tim toady". Is no myth in Perl.

blogs.perl.org - blogging the onion
Perl Mongers - Perl User Groups.
Planet Perl Iron Man
Hacking Thy Fearful Symmetry - Dancing the Haka - great perl related blog.
Five great Perl programming techniques to make your life fun again at Xaprb - map and grep, implement defaults with ||=,hash and array slices,executable regular expressions,dispatch tables of coderefs, oh my.

The Perl Programming Language - www.perl.org - home of Perl.
perl5i - Fix as much of Perl 5 as possible in one pragma - metacpan.org
Perl 6 / Perl 6
Modern Perl, by chromatic - Onyx Neon Press - great, up to date book...(2011-2012 draft)
Strawberry Perl for Windows - win32 binary distro, perl Makefile.pl, dmake,dmake install.
DWIM Perl - the Perl distribution that contains everything you'll ever need - based on strawberry perl.
Padre, the Perl IDE - install Padre::Perl, uses wxWidgets, very capable IDE.
Perl Circus - Perl Tricks, Tips And Traps.
Welcome to perlmeme.org - tutorials,faqs,howtos.
perl Out of memory! (with solution) at Red Mercury Labs - remember ulimit...
Perl has no switch statements. How do I avoid a long if-else-if pattern? - hashes!
Quick reference for common tasks:
Perl Programming - Wikibooks, collection of open-content textbooks
perlop - perldoc.perl.org - specifically the Quote-Like-Operators.

A nice function reference:
Perl Programming/Function Reference - Wikibooks, collection of open-content textbooks


Many times when you write PERL code, you want to use modules. These modules usually reside on the CPAN sites (The CPAN Search Site - search.cpan.org). To install them, find the module, download and install.

One nice utility I've found is the CPAN management shell.
Just run:
perl -MCPAN -e shell;
Then when you are inside the shell type:
install <module> (which could be something like MODULE::Name)

This will automatically download, unpack, and install the app. It will also grab any deps. that are needed when installing! Very nice indeed. :) For more information about it, search for: CPAN on the CPAN search.
Here's a single liner to install a module from the CLI.
perl -MCPAN -e 'install MODULE::ToInstall'
Also, if you for some reason need to reconfigure your CPAN options:
useful.things » Blog Archive » Perl CPAN reconfiguration

App::cpanminus - search.cpan.org - App::cpanminus - get, unpack, build and install modules from CPAN

Some really great PERL tutorials live here:
Alex Batko :: Programming :: Perl
Sam Graham's website > Perlblog
Introduction to References
How do I print a hash that has a hash within it?

CPAN wrong directory

I have had issues in the past when uninstalling and installing perl on machines with cpan using the wrong directory. If you find yourself with the same issue, try checking for a MyConfig.pm in your local directory. In windows, I found it in "Local Settings\Application Data\.cpan\CPAN\MyConfig.pm"

Nice way to start your perl file

#!/usr/bin/perl -Tw         # force taint checks, and print warnings
use strict;                 # install all three strictures
use warnings;               # print warnings
$|++;                       # force auto flush of output buffer


dos2unix/unix2dos in perl

perl -pi -e 's/\r\n/\n/;' *.ext #dos2unix
perl -pi -e 's/\n/\r\n/;' *.ext #unix2dos


teideal glic deisbhéalach » Blog Archive » Peruse popular Perl packages


Perl version 5.10.0 documentation - perldoc.perl.org - where to go for docs on perl.
Examples in Perl

create a hash from comma delimited list of name value pairs.

my %set_hash = map { split /=/ } split /,/, $setlist;


should PERL be considered a functional language?

I was a little surprised by this.
Derivative Function as a Closure in Perl - Derivative Function From Calculus as a Closure in Perl


Perl and C++

Don't forget SWIG.
Perl and C++ - Perl XS (the Perl native glue) and C++


PERL IDE in Eclipse

EPIC - Eclipse Perl Integration - EPIC is an open source Perl IDE (including editor and debugger) based on the Eclipse platform, compatible with Windows, Linux and Mac OS X. (http://e-p-i-c.sf.net/updates/testing)


PERL for file renaming

Recipe 9.9. Renaming Files
How to Bulk Rename Files in Linux (Terminal or GUI) | Webmaster Tips



array returned as undef

This made me take a double take. Try out the following:
my @array = undef;
 
if(@array) {
 print "defined\n";
} else { 
 print "undefined\n";
}
You will find that you get a defined value back! So when you return an array, returning undef does not make the returning @array undef. Instead, use the empty array ().

Logging in perl

8 Useful Log::Log4perl Recipes
Log::Log4perl::FAQ - Frequently Asked Questions on Log::Log4perl
Smart Logging With Log4per (PPT) or google quickview - really great set of slides.
Debugging Perl DBI - gives quite a good intro on DBIx::log4perl.


Email in perl

Sending Email with Perl Best Practice - I'll agree using MIME::Lite::TT::HTML is pretty awesome.


Random CPAN modules

FindBin - perldoc.perl.org - module figures out where the script was invoked. useful for relative paths...
IO-All README - metacpan.org
The home of asterisk-perl - A PERL module for Asterisk:
local::lib - search.cpan.org - - create and use a local lib/ for perl modules with PERL5LIB


Perl Web Frameworks

Meteor - perl web 2.0 http server
Catalyst - Web Framework - PERL MVC
PSGI/Plack - Perl Superglue for Web Frameworks and Web Servers
Dancer - Perl Web Framework for easy and fun webapp development
Web-Simple - A quick and easy way to build simple web applications - metacpan.org
jjn1056/Shutterstock-Guestbook-Web - GitHub - example web application using Web::Simple, Moo and HTML::Zoom.
yanick/Galuga - GitHub - Galuga - Yet another blog engine
HTML-Zoom - selector based streaming template engine - HTML::Zoom is the cure for JQuery envy.


Object Systems in Perl

stevan/p5-mop - GitHub - Meta Object Protocol, or MOP, to be perhaps included in a future version of Perl 5.
Qore Programming Language - embeddable multi-threaded programming language.
Moose - A postmodern object system for Perl
Jesse Luehrs / Moose - search.cpan.org
Dave Rolsky / Moose - search.cpan.org -Moose is a complete object system for Perl 5.
Call of the Moose - Moose blog
perl5i - Fix as much of Perl 5 as possible in one pragma - metacpan.org
Matt S Trout / Moo - search.cpan.org - Moo - Minimalist Object Orientation (with Moose compatiblity)
Object::InsideOut - search.cpan.org - support for implementing classes using the inside-out object model.
Object::InsideOut Quick Reference - Yani


DBIx

Testing DBIx::Class Models without the Database - Modern Perl Books, a Modern Perl Blog
DBIx::Class — An ORM for Perl that is extensible and flexible
Hacking Thy Fearful Symmetry - DBIx::Class::DeploymentHandler is Awesome
Arthur Axel "fREW" Schmidt / DBIx-Class-DeploymentHandler - search.cpan.org
DBIx::Class::Manual::Intro - search.cpan.org


Unicode in Perl

Unicode: Good, Bad, & Ugly
Tom Christiansen’s Materials for OSCON 2011
Unicode::Tussle - search.cpan.org
Last Updated on Monday, 23 April 2012 18:09