Perl

Using Common Sense With Perl

Using Common Sense With Perl

Since I was recently doing Perl work on the Boomerang project, I figured it would be a good time to finally try out common::sense, a CPAN module that, according to the documentation, will save a tree _and_ a kitten when you use it.  I like trees and cats, so Hell, why not try it then? Long standing advice in the Perl world has been to use warnings and use strict in your code.  However, the style of modern Perl has changed in such a way that it conflicts with those two things.  It is common these days to write something along the line of @{ $var->[0] } but with ‘use strict’ enabled, you’re not going to get away with it. You would instead have to write it as @{ defined $var->[0] ? $var->[0] : [] } No thanks.  That ...

0 Comment   |   Posted in Perl,Programming Languages,blog June 11, 2010
Perl Regular Expression \K Trick

Perl Regular Expression \K Trick

Regular expressions are a frequently useful tool in our profession, and Perl is probably the most advanced arena for testing your ability to wield regexes.  That’s because Perl has the most feature-rich regular expressions out there (that I know of anyways).  There’s always some new trick to learn about Perl regexes. Case in point: \K.  Let’s say you want to replace the end of every line that begins with ‘Parent Commit:’, where that string is followed by whitespace and a forty-character hash.  You want to replace the hash.  But you have to hold on to the beginning of the string.  Here’s one way to go about it: s/^Parent Commit:\s+[0-9a-f]{40}$/Parent Commit: $new_hash/gi This works, but repeating ‘Parent Commit’ is duplication we would like to avoid. s/^(Parent Commit:)\s+[0-9a-f]{40}$/$1 $new_hash/gi Here we capture the beginning of the string so that we can use insert ...

0 Comment   |   Posted in Perl,Programming Languages,blog June 04, 2010
Data Translation Service with IDS

Data Translation Service with IDS

Cyber Sprocket Labs first came across Inlet Data Systems (IDS) in January, 2005 via a simple Guru posting asking for assistance "converting data from one proprietary format to another".   The objective was to created an automated process by which a client could upload a file which would be automatically processed by the system & put it into a customer inbox for later retrieval in their required format. The System Today Over the years this system has grown into a fully automated, fully customizable web portal for sharing and translating data between clients. The system now supports over two dozen input & output file formats from a variety of sources.   New file layouts can be created and managed via a 100% web driven interface.  The administrator can select from several base files types such as CSV, XML, printed report layouts, fixed length, and multi-record fixed length formats.   A simple data mapping application allows ...

Comments Off   |   Posted in Perl,PostgreSQL,System Administration,portfolio January 05, 2010

Perl Introduction

About Perl Perl is a programming language originally developed for text manipulation on Unix systems. Perl is used for a variety of tasks on multiple operating systems, although the presence is most prolific on Unix or Linux systems. You can find Perl being used for web development, system administration, network programming, GUI development, and more. Perl Command Line Switches The Perl command line can be accessed from any SSH or telnet session on your Linux/Unix servers. Available commands for perl: Usage: perl [switches] [--] [programfile] [arguments] -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into @F) -C[number/list] enables the listed Unicode features -c check syntax only (runs BEGIN ...

0 Comment   |   Posted in Perl,Programming Languages,blog September 08, 2009

Perl Source Code Profiler

Here is a nicely done perl profiler that we've used in the past to help us with our Perl work.  You may find this useful as well.  Rather than describe the tool, we'll let the detailed documentation handle that for us. SYNOPSIS # profile code and write database to ./nytprof.out perl -d:NYTProf some_perl.pl # convert database into a set of html files, e.g., ./nytprof/index.html nytprofhtml # or into comma seperated files, e.g., ./nytprof/*.csv nytprofcsv DESCRIPTION Devel::NYTProf is a powerful feature-rich perl source code profiler. Performs per-line statement profiling for fine detail Performs per-subroutine statement profiling for overview Performs per-block statement profiling (the first profiler to do so) Accounts correctly for time spent after calls return Performs inclusive and exclusive timing of subroutines Subroutine times are per calling location (a powerful feature) Can profile compile-time activity, just run-time, or just END time Uses novel techniques for efficient profiling Sub-microsecond (100ns) resolution on systems with clock_gettime() Very fast - the fastest statement and subroutine ...

0 Comment   |   Posted in Perl,Programming Languages,blog November 08, 2008

Postgres::Handler

Our local updated perl docs. These enhanced notes will be published on our next push to CPAN.

0 Comment   |   Posted in Database,Perl,PostgreSQL,Programming Languages,blog May 08, 2008