If your program uses certain values which are defined as global variables at the top of the program, and which are kept constant throughout the program (Example: a filename, hostname, URL, user ID, or some other static configuration value), consider using Perl’s "use constant" mechanism to define that value instead. Here’s what it looks like:
use constant data_file => "/home/bill/data.txt";
use constant pi => 3.14159;
(more…)
Perl offers a variety of ways to convert numbers from one form to another (remember, "There’s More Than One Way To Do It").
(more…)
When programming CGI scripts for a web-based application, one common problem is that if there is an error all you see is "Internal Server Error" and you have to go look in the server’s log file for details. But sometimes you don’t have access to the log file, such as when it is hosted on an ISP’s server. Here’s a way to get those errors sent to the screen where they can be of use to you.
(more…)
Try the Text::Wrap module if you need to reformat text to fit in an 80 character window, or whatever other size you might need. This is a module that comes with Perl, so you don’t have to worry about installing it or whether it will be installed on a machine you will be running your programs on.
(more…)
Copyright © 1995-2007 William R. Ward dba Bay View
Training. All Rights Reserved. “Bay View Training”,
“Bay View Consulting Services”, “Bay View
Software”, the sailboat logo, and the domain name
“bayview.com” are trademarks and/or service marks of
William R. Ward dba Bay View Training. For more information,
contact
webmaster@bayview.com