We have released version 1.0 of our Perl Common code that is used in many of our Perl-based web applications. The distribution is available, for free, from our
website. The files and functions with their descriptions are listed below.
ActivityTracking.pl
AddActivity( Activity, Parameters ) - Adds a new activity to the ActivityTracking table in a MySQL Database. This is used by our systems to track usage and user trends.
Advertisements.pl
LoadAdvertisements() - Loads a list of advertisements from an Advertisements.dat file.
GetRandomAdvertisement( AdvertisementType ) - Returns the HTML code to a random advertisement of the type specified.
Debug.pl
LoadDebugger() - Initializes the logging system by getting the log file name from the Settings.dat file.
Log( Message ) - Sends the message passed in to the log file.
ClearLog() - Empties the log file.
PrintLog() - Outputs the contents of the log file to the browser for viewing in some type of an admin system.
Email.pl
SendEmailMessage( ToAddress, FromAddress, Subject, FileName ) - Sends an email message. This function uses the HTML scripting engine we have developed to allow the use of template files to build the email message.
FormData.pl
LoadFromData() - Loads all of the "get" parameters sent to the script into a local hash for easy access.
GetFormDataValue( Name ) - Gets the value for the specified parameter.
GetFormDataFile( Name ) - Gets the file data for a file that was posted to the script.
GetUserName() - Deprecated.
get_form_data() - The actual function that does the work of parsing all of the script's variables.
HTMLScript.pl
InsertHTMLFile( FileName, Parameters... ) - The main function of our HTML scripting engine. The first parameter is the name of the HTML template file, and the rest are the parameters to merge into the template.
InsertHTMLFile_ToString( FileName, Parameters... ) - The same as InsertHTMLFile, except the output is returned as a string variable for further processing.
MySQL.pl
CreateDBConnection() - Creates a connection to the database specified in the Settings.pl file.
RunSQLQuery( SQLQuery ) - Runs the SQL Query that was passed to it. Returns the results as an array of hashes.
Disconnect() - Disconnects from the database.
Settings.pl
LoadSettings( SettingsFile ) - Loads the Name=Value settings stored in the Settings.dat file passed to it.
GetSetting( SettingName ) - Returns the value for the setting passed to it.
Utils.pl
GetCookie( CookieName ) - Returns the value for the cookie passed to it.
SetCookie( CookieName, SiteDomain, ExpireDate ) - Creates a cookie according to the information passed to it.
BubbleSortArray( Array ) - Performs a bubble sort on the array passed to it.
GetDirectoryList( Path ) - Builds and returns an array filled with a list of directories under the passed in path.
GetFileList( Path ) - Builds and returns an array filled with a list of files under the passed in path.
GetCurrentDateFormatted( time ) - Returns the current date formatted in a human readable way.
GetCurrentTimeFormatted( time ) - Returns the current time formatted in a human readable way.
GetCurrentDateFormatted_MySQL( time ) - Returns the current date formatted in the way MySQL databases expect it.
GetCurrentTimeFormatted_MySQL( time ) - Returns the current time formatted in the way MySQL databases expect it.
GetCurrentDateFormatted( time ) - Returns the current date/time formatted in a human readable way.
GetCurrentDateFormatted_MySQL( time ) - Returns the current date/time formatted in the way MySQL databases expect it.
Utils_Graphics.pl
CopyImageResized_ImageMagick( SourceImage, DestImage, ResizedWidth, ResizedHeight, TotalWidth, TotalHeight, DestX, DestY ) - Resizes the specified image using the ImageMagick library.
CopyImageResized_GD( SourceImage, DestImage, ResizedWidth, ResizedHeight, TotalWidth, TotalHeight, DestX, DestY ) - Resizes the specified image using the GD library.
CopyImageResized( SourceImage, DestImage, ResizedWidth, ResizedHeight, TotalWidth, TotalHeight, DestX, DestY ) - Resizes the specified image using either the ImageMagick or the GD library based on a setting in Settings.dat.
I will be making some examples and Perl tutorials available in the near future, so stay tuned. Version 1.0 of the Cleghorn Creations Perl Common Library can be obtained by clicking
here.
For more help with perl watch this blog and check out some of the recommended reading.
Recommended Reading:
 | Beginning Perl Web Development: From Novice to Professional Steve Suehring Average Customer Review: | | |