PERL Programming Language

On this page you will find some Perl-related links and Perl scripts that I wrote. If you find something useful and want to incorporate it into your program, feel free to do so. No need to ask for permission. Just copy and use whatever you like. I started learning Perl in 2016, so I am still a beginner. I use Notepad2 text editor and TinyPerl 5.8 on Windows XP, but all my scripts should run fine on Linux too. I make sure that my scripts can run well on Perl 5.004 on DOS as well.

Perl is a beautiful language. It's very versatile. It resembles assembly, BASIC, C and JavaScript in some ways. It is a mixture of several languages. Perl can be used for website back end applications as well as Linux/Windows scripting. Perl even runs on Mac OS and DOS. It usually comes preinstalled on Linux systems.

Perl Websites

My Perl Scripts

If you trade stocks, you will have to report your sales to the IRS. During tax season, Robinhood's platform allows you to download the trades in PDF form. Most PDF viewers allow you to convert the PDF to TXT. And this Perl script will convert the TXT to CSV so you can import it into Excel. If you make a lot of trades, this tool comes handy. It can save you days of tedious work and do it in 5 seconds. This program can also be useful for accountants who have to enter a lot of Robinhood trades. This tool makes it super fast to process a large number of trades. The output will show the security name, number of shares, date acquired, date sold, profit or loss, cost basis, wash sale, etc.

This program is the same as the one above, but this works for 1099 tax PDF files released by Charles Schwab brokerage firm. This program takes TXT files and converts them to CSV.

This ZIP file contains Notepad2, TinyPerl 5.8 for Windows (executable) and and It's 12 megabytes. This is all you need to run my perl scripts. Expand to a folder called C:\PERL and follow the instructions in README.TXT. (Note: Perl was invented by Larry Wall, and TinyPerl was built by Graciliano M. P. in 2003. Notepad2 was created by Florian Balmer.)

This perl script compares two directories. It compares directory1 and directory2, and displays a list of files and directories that do not exist in directory2.

This script solves the knapsack problem. The knapsack problem goes something like this: You have 100 items each with different size. And you have a bag which you must fill all the way to the top. You have to figure out how to fill the bag in a way that you end up with the least amount of empty space. This script tries to find a combination of numbers whose sum equals 500. The random numbers are between 1 and 500. The first script solves the problem step by step, displaying what happens at each step. The second script just solves the problem and displays the results without "debug" messages.

This tiny script was a programming exercise I saw somewhere. It sorts email addresses by domain.

This Perl script minimizes JavaScript code by removing comments and all non-essential spaces from a JS file.

This Perl script deletes duplicate JPG files within a directory. Sounds like a great idea at first, but it's not. If I have 3 identical JPG files called "Charles.jpg" and "Copy of Charles.jpg" and "Florida.jpg" then I want to keep the first one, but the program doesn't know how to come to that decision. So, it will ask the user each time what to do. This makes the program really slow. If you have thousands of duplicate files, it will take forever...

This Perl script demonstrates the QuickSort algorithm. This program sorts an array of numbers.

This program reads all HTML files in the current directory and extracts META tags and saves them in an output file. (This program can be used to extract other things from HTML files as well, not just META tags.)

Similar to the program above, this program reads all HTML files in the current directory and extracts all the links and writes them to a file.

Displays the contents of a directory.

Analyzes file contents and displays what percentage of a file is binary vs plain text.

This script converts all Linux/Apple text files in the current directory to DOS format.

This function converts any binary string to plain text format that contains nothing but letters and numbers. The algorithm tries to compress the string by using a simple RLE algorithm and grouping characters depending on how often they are used. So, in some cases, the output will be shorter than the input. Most of the time the result will be smaller than what we can achieve using the escape() function or string2hex() function or base64 encoding.

This script displays the prime numbers under 1 million, and it contains functions for factoring numbers and finding the common factor.

This script calculates the first 15 digits of PI using the BBP formula which was discovered in 1995 by Canadian mathematician Simon Plouffe.

I use TinyPerl 5.8 on Windows XP. Unfortunately, many of the modules are not working on my computer, so I write my own subroutines. I use this Perl "toolbox" file to grab what I need.
These are subroutines for working with files... This is a minimized version, which means spaces have been removed. It includes the following subroutines: ReadFile() CreateFile() AppendFile() WriteFile() isReadOnly() FileExists() FileSize() GetCurrentDirectory() GetTempDir() TempFile() SplitPath() MergePath() CreatePath() GetPath() GetFileName() toDOSPath() toLinuxPath() FixPath() GetFileDate() SetFileDate() FormatDate() GetNumbers() GetDriveList() QuotePath() isMatch() _isMatch() isFileName83() Trim() TrimChar() FindChar() SafeFileName()