NEWSLETTERS
 

CIO.com updates, insights and advice on technology, management and your career.

 
 
 
LEADERSHIP
 
CIO Executive Programs
The Leader in Face-to-Face Education for Senior Executives

Offering regional and national programs, CIO (and CSO) events bring together some of the most respected names and thought leaders in information technology and security. Presented by CIOs and other senior level executives, these invitation-only programs offer timely topics and strong networking. Learn More »

 
CIO Executive Council
A Peer-Advisory Service and Professional Association for CIOs

Social Responsibility's Strategic Benefits

December 15, 11:30 AM - 12:30 PM US/Eastern (GMT-5)

Join Ed Granger-Happ, CIO of Save the Children, for a discussion of how creating an organization that is socially responsible improves staffing, retention, leadership development and overall corporate health.

Working With and Communicating to Your Board of Directors

January 13, 2009, 4:00 PM - 5:00 PM US/Eastern (GMT-5)

CIO panelists who will share tips and experiences working with their boards: Twila Day of SYSCO; Jeff O'Hare, West Corp.; Marc West, formerly with H&R Block.

IT's Role in Growing Mid-Market Companies

January 14, 4:00 PM - 5:00 PM ET (GMT-5)

Mid-market Council members will share their companies' stories and challenges in driving or coping with growth. Panelists represent Veterinary Pet Insurance, Medicis Pharmaceutical, and Intrax Cultural Exchange.

More / Register »

Learn more about the CIO Executive Council »



 
 
RESOURCE CENTER
 
 
 
SUBSCRIBE TO CIO
 
Are you involved in setting the direction for your company's IT budget or strategy?

Apply today for a FREE subscription to CIO Magazine!

 
 
 

You Used Perl to Write WHAT?!

Every programming language has its strengths...and its weaknesses. We identify five tasks for which perl is ideally suited, and four that...well, really, shouldn't you choose something else?

 

January 24, 2008CIO — We all know that when faced with a job to do, we usually tend to reach for the most familiar tool in our belt. And while perl is certainly a versatile tool, it isn't the right tool for every job.

Perl is the granddaddy of the open-source scripting languages, with the 1.0 release seeing the light of day way back in 1987. By comparison, PHP wasn't released until 1994, and Python didn't have its 0.9 release until 1991—only the Unix shells themselves have an older pedigree. The O'Reilly "Camel" book (Programming perl) has been a ubiquitous presence on cubicle bookshelves for decades.

Like any language, perl has its strengths and weaknesses. With that in mind, here's some recommended uses and abuses of the elder statesman of scripting.

The Good

  1. Pattern matching: Perl's greatest claim to fame has always been the tight integration of regular expressions into the base language syntax. For most developers, perl was the first time they ever used a regular expression.

    As a result, perl has always been the go-to language for any task that involves pattern-matching input. A typical use of this capability is to scan an input stream for name/value pairs and split them. Another is parsing log files with a fixed but variable length format. It's not for nothing that a lot of the popular log file auditing packages are written in perl.

  2. In-place editing: Combine regular expressions with the ability to edit files "in place" from the command line, and perl makes a dandy tool for performing a batch modification on a group of files. For example, suppose you have renamed the /home/george directory to /home/curious, and want to update a few hundred scripts in the /usr/lib/yellowhat directory to point at the correct new path. The following one-liner will do just that:

    # perl -i.bak -p -e "s#/home/george#/home/curious#" `find . -print`

    Now, this is a fairly simple example and could have easily been done using a tool such as sed, but the important thing is that you could have used any arbitrarily complex perl program as the filter, and done highly complex manipulations. Imagine an area code getting split and having to replace a single area code with one of two depending on the original exchange in hundreds of files. In perl, it would be a snap.

  3. A replacement for shell scripts: One of the worst things about shell scripting—whether in bash, sh or csh—is that the syntax of the scripts themselves is fairly hard to read. By using perl as a scripting language instead of a "traditional" shell, you can use much more C-like syntax without sacrificing functionality.

  4. As a database manipulation tool: One of perl's strengths has always been the strong database interoperability through the DBI and DBD libraries. If you need to create a quick database report, or convert between a database and some other form of data storage, you can very easily whip up a little utility using perl in very short time.

  5. As a cross-platform language: Because perl is interpreted, perl scripts don't need to be recompiled when moved from platform to platform. And because companies like ActiveState have produced strong ports of perl to platforms such as Windows, most perl programs will run without modification even if they do advanced things such as database connectivity, file system modification or network programming.

Loading...
 
WHITE PAPERS

Enterprise Findability without the Complexity

Effective findability is fast becoming a necessity in the enterprise. Traditional approaches to addressing findabi...
 

Grappling with Application Management

Dell provides services that can help every step of the way when applications must be updated, installed or migrated...
 

Deploying Windows Vista to the Desktop: Get It Right with Dell

Dell has improved PC deployment activities through patent-pending automation technology and offers an array of serv...
 

WEBCASTS

Remote Infrastructure Management - What Your Peers are Thinking

The buzz around Remote Infrastructure Management (RIM) has reached a fever pitch. View now for a first-hand look.
 

IT Disaster: It's Not a Matter of If--It's a Matter of When

Bob Melk, publisher emeritus of CIO magazine, talks with Accenture's Gil Brodnitz about the very real and growing t...
 

Google Search Appliance - New Features

Learn more about the latest features of the Google universal search solution, including increased index capacity to...
 

Resource Alerts

Get instant email notifications by topic when white papers, webcasts, and case studies are added to our library.

 
IT Jobs
 
 
 
ABCs
 

Just the basics, please. Sometimes we all need a refresher or we need to make sure our team and our colleagues are all on the same page.

Over 25 tutorials on everything from business intelligence to virtualization.

 
 
FEATURED SPONSORS
 
 
 
SPONSORED LINKS
 

Efficient by design: Watch this flash demo of the Quad-Core AMD Opteron Processor

HP and Oracle deploy unbreakable computing infrastructure at Replacements, Ltd.

File Integrity Monitoring: Prove compliance and secure your IT environments

Affordable technology-no compromise. HP server solutions

SOA Educational Library at the TIBCO SOA Resource Center

CIO Viewpoints: Migrating to Exchange 2007

Thrive during global disruption. Cisco video featuring Juan Enriquez

A new level of interoperability. Make IT Work As One@novell.com

Protect data-HP All-in-One and Disk-Based systems

Businesses Transform with VMware Virtualization

Download the free CIO Starter Kit to access useful resources created by top CIOs

Top 5 Questions to Ask about Server Virtualization

Virtual Storage Best Practices

The Business of Managing Content: Xythos Document Management & Microsoft SharePoint

Virtualization Benchmark and TCO Analysis-Read Now

White Paper: Scaling Down HPC for Smaller Organizations

White Paper: Never Enough Compute Power?

Microsoft Windows Vista Cost and Benefit Estimator

White Paper: Efficient Desktop Application Management

White Paper: Take your Call Center to the Next Level

Is Your WLAN Helping You Comply with Security Guidelines of the PCI Standard?

White Paper: Improve Employee Efficiency and Reduce Telecom Costs

White Paper: Green Issues for Networking

New IDG Survey Results on Data Center Automation

A CISO's Guide to Application Security

Renowned Engineering Institution Chooses AMD Processor-Based Servers

Corral, configure and control all your mischievous machinery with a Lantronix device server

Spend less. Get hosted UC. Get cash back. It's easy under a Cypress

Predict the future with HP Insight Power Manager

Log onto Hitachi True Stories, films inspired by the next great achievement

Earn PROFESSIONAL DOCTORATE Part-Time, Online at Syracuse University's iSchool

Make IT Work As One@novell.com

Predict the future with HP Insight Power Manager

HP LaserJet P4014n printer starting at $799 after $100 IS. www.hp.com

CIO Starter Kit includes useful resources created by top CIOs. Free Download>>

Innovation: Extravagance or Necessity in Today's Economic Climate?

New Benchmarks for VMware Among Major Storage Vendors

How to Start a PMO & Realize the Benefits Fast

Leveraging Social Computing Technologies for ERP Applications

Server Virtualization Benchmark Results

Learn to Leverage Maximum Computing Power

Windows Vista: Essential Benefits and Deployment Strategies

Best Practices: Safe and Secure Hardware Asset Recovery

White Paper: Migrating to Windows Vista and Microsoft Office 2007 Together

White Paper: Enabling Next Generation IP Communications

White Paper: A Cohesive Network Security Approach

Why Your Firewall, VPN, and IEEE Aren't Enough to Protect Your Network

Dramatically boost network capacity and speed-up to 600 Mbps

White Paper: The Roadmap to Data Center Automation

17 Ways to Reduce Cost in IT