oreilly.comSafari Books Online.Conferences.


Putting Perl to All-Purpose Use

by Howard Wen

Burlington Coat Factory has a record of adopting technologies like UNIX and Java. In this tradition, the company's Director of Networking, Matt Fahrner, has been using Perl for numerous needs: managing IP systems, managing an LDAP database for proxy servers, and generating reports on statistics gathered through authorization subsystems.

Depending on the application, anywhere from fifteen to thousands of Burlington Coat's users are served under Perl. One application supplies menuing for all of the company's end users, thousands of them. Others fulfill report-generating, client/server, and system needs. Pretty much anything requiring parsing is a good use for Perl, according to Fahrner. "We use it as an all-purpose scripting language for just about anything you can think of."

Interested in learning more about Perl and other Open Source technologies? The O'Reilly Open Source Convention is the place to go.

Burlington Coat was an adopter of Perl after-the-fact, Fahrner admits. The company started out using a combination of C programs, c-shell and bourne-shell script solutions. "In many cases, this was a lot more work and led to non-portable, obfuscated code," Fahrner says. "Eventually, about 4 years ago, we started to recognize that Perl was a good tool for the same tasks."

Why Perl was Right for Burlington Coat

Perl has the ability to do complex parsing while maintaining a complete and robust syntax. "Because almost all the system capabilities of the C language exist within Perl, and it exhibits the strong but simple-to-use parsing capabilities of languages like awk, Perl makes for an incredible systems programmer's tool," Fahrner says.

"It completely lends itself to the maintenance of things like DNS, where heavy parsing and networking is required," he points out. "However, because it is a complete language, it is also very useful for general programming. The language is not difficult to learn for the average application developer, and its many tool kits make it ideal for database and user interface applications."

Another major benefit of Perl, Fahrner found, is the quick turnaround from coding to running. "Not having to recompile and link between test runs saves enormous development time," he says. "Yet, with its on-the-fly compilation, its code runs efficiently enough to be used in places we otherwise wouldn't consider scripting languages. It's a good trade-off between the simplicity of scripts and the benefits of compiled code, and this is true at many levels."

Fahrner was personally responsible for taking tens of thousands of lines of credit-card-authorization data and producing a report which the company could use to track errors and other information. Naturally, he wasn't looking forward to this task. "It would be nearly impossible in bourne shell or awk or C to make it as dynamic as I wanted," he says. "I knew it would require lots of custom structures, allocations and sorting--all of which are a lot of work."

Though he had never programmed in Perl, Fahrner had a preliminary report functioning, which was a lot better than he had ever hoped, in less than an hour. "Using hashes I was able to easily categorize and sort the data and generate statistics by numerous categories," he said. "Because it turned out to be so simple, I even threw in some graphing in ASCII to better illuminate the data. Not only would this have been far more work in another language, I probably wouldn't have created as sophisticated a report because of the complexity involved."

Another example of Perl's efficiency and effectiveness involved a simple but handy tool that other programmers in the company had created in C. The problem was that it had become a challenge to port to the company's numerous operating systems. The program was a basic client-server application which retrieved an employee's phone extension from the server's Oracle database in response to the employee's name. "This wasn't a particularly difficult program to write for someone who had written socket code before, but a socket programmer's time is at a premium at Burlington Coat," Fahrner says. "We were finding that continuing to port this was a real pain.

Learn how large and small companies are putting Perl to work by reading more Perl Success Stories.

"So one of our application developers got the bright idea to convert the C program to Perl. This particular programmer had never worked with sockets, but with the very powerful Perl libraries he was able to put together this working socket application in just a few hours." The resulting program took up less than a page of code and was entirely portable to the other operating systems in the company. "In fact, we use exactly the same script via an NFS mount on at least three different binary incompatible architectures," Fahrner says.

Burlington Coat Likes the Open Source Bonus

While his company did have some concerns about using Perl simply because it was viewed as somewhat of a hacker's language, Fahrner says that this attitude "has since completely turned around and in fact [open source] seems to have been accepted as the preferred standard."

Once Burlington Coat accepted Perl, the company came to appreciate Perl's open source nature as a bonus. "If there were bugs, we could potentially solve them ourselves through our own debugging," Fahrner says. "It also meant there was a greater community working to find bugs and fix them. Additionally, we can influence Perl's evolution directly, either through simple suggestion or through actual code contribution. This is less likely with the more fixed or proprietary programming languages."

Sponsored by: