I have two primary perl sections, my general utilities and my
spam utilities.
Just in case it is not obvious, the link general utilities loads a page that
allows you to see these utilities including the source code. The other link, spam utilities,
is for the same purpose.
My general utilites include a package BayesianTokenCounter
package to tokenize files.
and then determine the probability that another file is in one group or another.
I use this to determine if an email message is, or is not, spam.
There are perl scripts to use this package with the spam utilities.
The DeepCopy
package is used to make clean copies of data structures that include references.
To look at the actual code, follow the general utilities link.
The SmallLogger
package allows for logging. The output can be echoed to the screen
or a file. Output is echoed based on what type of message is printed.
To look at the actual code, follow the general utilities link.
The XMLUtil
package is used to convert data structures to XML and the XML back into data structures.
To look at the actual code, follow the general utilities link.
The DateUtil
package is used by the logger to format time/date strings.
The output of the logger is configurable to include different things
including formatted time/date stamps in both the filename
and each output line.
To look at the actual code, follow the general utilities link.
The SafeGlob
package was originally written to avoid a problem in the glob method.
If there are too many files in a directory, then the glob method would fail.
Added functionality has been added to allow for searching based on both
file specs and regular expressions. This also allows for recursing subdirectories.
To look at the actual code, follow the general utilities link.
The StringUtil
package has methods for various string manipulations.
To look at the actual code, follow the general utilities link.
These were written so that I could avoid spam on my computer.
There is a better write-up here
and the utilities are here.
Formatting And Extracting Dates And Times In Perl
There are two primary reasons that people come to my website if they do not already know me.
The primary reason is of course Macro Programming using OpenOffice. The second reason
is to try and figure out how to parse dates and times using PERL.
If your only purpose in life is to format and use dates and times, then simply download a copy of my
date utility code. You can see a pretty version of it if you like, or simply see how to use it.
If you want to do it the hard way - meaning you want to do it yourself - it is not that difficult.
First, call the time() function to find out what time it is. Next, pass this value to localtime function to break this value into
component pieces.
The returned year is the number of years from 1900, so the year 2004 is returned as 104.
Boy did this annoy some of my PERL programming friends!
I must admit that I used some interesting code in the time_date_str routine, take a look at it.
If there is call for it, then I will provide some more information.