July 1998 Archives

How Perl Creates Orders For The Air Force


This article is the first in a series that will provide examples of Perl solving real-world problems, particularly in an organization. If you have your own real-life story to tell, send it to Perl.com Editor.

How many times have I been in a meeting where someone questions using Perl for a key business application? Someone says we shouldn't use Perl because it is freeware. Most programming languages, I argue, are not owned by anyone. Are C and C++ any different from Perl in that regard? If I win that point, someone brings up yet another. I once had a webmaster tell me that we shouldn't use Perl because of virus concerns.

I just have to accept the fact that educating everyone about Perl is part of the price I pay to use Perl. Fortunately, most people are easily persuaded and when I start talking about Perl, it is hard to shut me up.

While I was in the Air Force, I worked in the Base Network Control Center. It was our responsibility to handle all computer hardware and software purchases for the base.

The process of ordering equipment was not simple. Many forms had to be filled out and then signed by the right people in all of the right places.

We had created a database to track all of this for us but it was still a difficult process. A single order might have to be on 10 different forms and have 2 or 3 different documents generated. Also, there were 13 different times that the database entries had to be updated, from the start of an order until the equipment was received and picked up. This left too much room for human error. Updating the database was a bother and many times it just didn't get done. Because of this, the integrity of the database was always in question. Even if the database was religiously maintained, the ordering process itself was cumbersome. With nearly 1,000 orders per year, this was a lot of work!

Since I was doing Web development for the base, I proposed a web-based solution written in Perl. In a meeting to discuss the project, I was candid. I said I wasn't sure I could do it but I'd give it a try. There were other solutions proposed but my Web-based solution won out.

We had a list of requirements for the application:

  • Web-based database
  • Customer ability to check their order status
  • Eliminate unnecessary database entries
  • Automate as many necessary entries as possible
  • Generate forms from a web-based interface
  • Generate letters automatically when necessary
  • Notify customers via e-mail when their equipment arrives

The new Perl application was built around a database. It was actually a flat-file text database. There were two data files that we used; open and closed. The open database had around 1,000 records, and the closed database had around 6,000 records. Each record had 33 fields. (In retrospect, I might not do it with text files again. On a smaller project, text files are fine but something of this size should have been on a real database.) Overall, the speed wasn't a problem since 95% of what we did was on the smaller, open database file.

Our personnel were able to create and update database entries from their web browser. The application also created forms and other documents that they needed. For instance, we generated printable order forms compatible with the Delrina Form Flow software that was in place for creating equipment orders. We also stored the form data so that forms could be called up and changed or reprinted at a later time.

We also handled other documents in Rich Text Format (RTF), which the Perl application could easily manipulate. We could modify the RTF files on the fly and send the results to the client for printing.

Once the equipment arrived on site, our personnel used the Web interface to bring up the order number, check which items had come in and the database was updated. Perhaps the best feature was that the customers were automatically e-mailed a message that listed the items that had come in.

This solution saved us an official estimate of 900 man-hours per year. That is all that I could justify on paper. I personally think that this estimate was low. It simplified so many areas of the ordering process that I could safely say it saved well over 1,500 man-hours per year.

Not only did it save time:

  • Our customers were able to check the status of their orders from their desktop
  • Our customers got the most current information available
  • The database integrity was greatly improved
  • The manual database updates were cut down from 13 to 5
  • Many database functions were masked behind the web interface
  • Saved 20-30 phone calls per week because customers could check status on their own

This is just one example of how Perl can be used to create programs that simplify difficult processes and save time and money for any organization. Sure, there are many other languages and commercial applications that you can choose to develop in, but they too have pros and cons. I have had many of the more seasoned web developers ask me "why don't I develop in Java?" I ask them back "Why don't you develop in Perl?" I have never been faced with a Web application that I could not do in Perl.

Perl Builder IDE Debuts


Overview:
Perl Builder, by Solutionsoft, is the first integrated development environment (IDE) for Perl. It allows you to develop and test Perl applications in a Windows 95/98/NT environment.

Test Equipment:
I tested Perl Builder on a machine with a Cyrix 6x86/200MHz processor and 48Mb RAM using Windows 95 and then the same machine using Windows 98. Both of these test machines used the ActiveState Perl port. I also tested Perl Builder on a Pentium 166 with 96Mb RAM running Windows NT. This machine used the latest Gurusamy Sarathy port of Perl.

Installation:
Installing Perl Builder took about 5 minutes. It was very simple and I had no installation problems. I was surprised by the nice, clean interface and yet the program was only around 750kb in size before installation! To me, this is remarkable in an age where IDE's can easily take over 100Mb of space. Granted, Perl Builder is really just a text editor that integrates with Perl so there are no libraries or any Perl-related files included with the program.

To use Perl Builder, you need to have Perl installed on your system. You can use either the ActiveState Perl port or the "Gurusamy Sarathy" port of Perl. Neither of which come with Perl Builder, but Solutionsoft does provide links so that you can easily download them. I recommend the "Gurusamy Sarathy" version.

Once installed, my first task was to run through the tutorial provided. The tutorial walks you through creating a "mailto" form using an HTML form that they provide. It worked as advertised and was an easy-to-follow tutorial that provides you with a good overview of the IDE.

Programming Environment
Perl Builder is basically a text editor that has been written specifically for writing Perl scripts. Perl Builder provides a simple programming environment that is easy to get comfortable with. The different windows in the IDE are "tabbed" for easy access. The normal tabs are Main Script, Input Values, and Output: HTML/Text. Other tabs, like errors, are added as needed.

The Perl Builder Window
Figure 1: Perl Builder's visual editor

The Main Script tab is the area where you actually write the script. The code that you write is automatically color-coded by Perl Builder and the colors are user-customizeable Having color-coded Perl code makes viewing the code much easier. I found that once you get accustomed to the colors, you can quickly scan the code for what you are looking for.

The Input Valuestab allows you to specify either the values that you would have sent from an HTML form if you are writing a CGI script. Or, from STDIN if you are writing a non-CGI script.

The Output tab shows you what output your Perl application produced. If you are writing a CGI script, there is a button on this tab that allows you to view the code in a web browser. Perl Builder actually takes the output from your script, and produces a local HTML file for the browser view.

The Errors tab does exactly what you would expect it to do, it shows you any errors that were generated by your script. The feature I liked here is that you can double-click on the error, and you are taken right to that line of code on the Main Script tab.

When a CGI script generates one or more e-mail messages, Perl Builder also provides a tab that shows you what the e-mail(s) would look like.

Debugging
Perl Builder includes some great features for debugging your code. You can set breakpoints, watches, step through your code or do just about anything that an IDE debugger should do. You can also run with "strict" or evaluate your code with the -w flag.

Nice Features
Perl Builder has many nice features. My favorites were:

  • Editor-scripts
    The Editor-scripts menu item, my favorite tool, allows you to write Perl scripts that will be performed on your code. Solutionsoft includes a few like block-comment and block-uncomment. I wrote a quick one that allows me to add line-numbers to my code and replace all of the < and >'s in my code with their HTML equivalents. This saves me a great deal of time when I write code for articles. Now I just highlight the code, and let Perl Builder do everything for me.

    To use the editor scripts, all you do is highlight the code you want to perform the action on, and choose the appropriate item from the menu. The code is executed only on the part of your script that you highlighted. Plus, you don't have to learn any new "scripting languages", it is all customized with Perl code.

  • Regular Expression Search/Replace
    This feature allows you to use the power of Perl and create complex search/replace regular expressions that are executed on your script.
  • CGI Wizard
    The CGI Wizard in Perl Builder allows even non-programmers to write CGI scripts that can accept HTML form data, validate the entries, e-mail multiple messages to multiple recipients and generate response pages on-the-fly. The CGI Wizard steps you through the process and does 99% of the work for you. All you have to do is choose an HTML form, the wizard imports the variables and then steps you through the rest of the process.

Weaknesses
Perl Builder is a great product, but there were a few items that I'd like to see addressed.

  • The menu bar at the top of the IDE did not have a print button. I like to print my code out and draw all over it, while this is just a minor detail, I'd like to see it added.
  • When generating forms on-the-fly, Perl Builder only allows you to create and test the first form. You cannot test scripts on code that was dynamically generated. The ability to test the dynamically generated forms would add to the complexity of the program, but it is needed to fully test CGI scripts. I write many scripts that dynamically generate HTML forms and call themselves with these new forms.
  • When using the watch portion of the debugger, I found that when I closed the watch window I began getting errors from Perl even though none of the code had changed. I found that if I closed Perl Builder and restarted it, all was well again.
  • I also ran into a few graphic glitches while using the program. The graphic problems were much better than in the beta that I had tested previously but they were still annoying. I am confident that as this program evolves, this is still version 1.0 of the program, these glitches will be worked out.

Wrapping It Up
Overall, Perl Builder is a great program and is something that should have been developed a long time ago. It is a great tool for both beginning Perl programmers, and experienced Perl programmers. Perl Builder's clean interface and powerful features take much of the unnecessary work out of Perl programming.

While it is not perfect, and can't handle some of the more complex Perl programs, it is a great environment for developing most of your CGI scripts. The ability to easily test your scripts locally is something that makes CGI programming much easier.

The price for Perl Builder is $149. Although I think that the price is reasonable, I think it would do better if the price was around the $99 range. Perl developers have become accustomed to free software and I think that they may have a hard time spending almost $150 for a "helper" program.

Overall, I give Perl Builder a 4.5 out of 5 camel rating.

Author's note: I was contacted by Solutionsoft and told that a version 1.0a would be released sometime this week. Version 1.0a is supposed to fix many of the bugs that we found in version 1.0. An update to this article will be added when I have had a chance to evaluate the new version.

Visit the home of the Perl programming language: Perl.org

Sponsored by

Monthly Archives

Powered by Movable Type 5.13-en