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

ROBINHOOD.PL (99 KB)
This program converts Robinhood's 1099 forms to CSV format. 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.

If you use Windows, you may download the Offline Installer (1.2 MB) which will install and run this perl program. More Info

SCHWAB.PL
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.

TINYPERL.ZIP
This ZIP file contains Notepad2, TinyPerl 5.8 for Windows (executable) and Robinhood.pl and Schwab.pl. 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.)

DIRCMP.PL
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.

BMPINFO.PL
This command-line utility reads one or more BMP image files and prints everything that one could possibly find out by analyzing the BMP file's header. It tells you a lot more than just the image width and height and the number of colors. It also displays the colors in the palette. Displays a health % so you can see if the header is damaged at all. It prints data pointers, color masks, format, encoding, print size, padding, header size, Bitmap version. Has an /S switch so it can automatically find BMP files in sub-directories as well.

MEM.PL
This program displays the uptime, processes, threads, the amount of free memory, used memory and total memory in the system. It has been tested on Windows XP/7, Ubuntu Linux and MacBook. (It did not work on the MacBook.)

KNAPSACK1.PL and KNAPSACK2.PL
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.

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

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

PERLEDIT.HTA
This is a Perl Editor for Windows that supports code folding. It's a HTA file which I wrote in JavaScript. When opening a pl script, it reads all the subs and displays them in a table of contents. From there, the programmer can select any sub and view/edit that single sub. It does not support find/replace or syntax highlighting. NOTE: When you close the program, it always saves the Perl script that you were editing (it won't ask if you want to save it or not).

DELDUP.PL
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...

BMP2HTML.PL
This Perl script can read any kind of BMP file and converts the image to a HTML TABLE element, allowing you to post pictures in PerlMonks or other forums where the HTML IMG tag is not allowed but the TABLE element is allowed. See an example here.

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

META.PL
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.)

HREF.PL
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.

FILELIST.PL
Displays the contents of a directory.

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

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

RUNPL.PL
This perl script can package a bunch of perl modules and perl scripts into a single JS file that can execute on a Windows computer that does not have Perl installed yet. (The JS script works like an offline installer that unpacks TinyPerl 5.8 on the Windows computer and then executes the custom scripts without any prompts or questions. Just double-click & run.) WARNING: THIS SCRIPT IS BIG. Don't open the link unless you're ready to download a 1.2 megabyte perl script. It's that big, because it contains a copy of TinyPerl 5.8 Windows executable! (The Robinhood offline installer mentioned above was generated by this tool.)

TXTBIN.PL
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.

PRODUCTDB.PL
This is a very simple product database script. Click here to see it in action.

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

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

TEMPLATE.PL
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. This file includes the following subroutines:
_filename() escapeinit() jstimestamp() shiftrstr() _ismatch() escapestring() lastchar() shiftstring() abort() everyother() lc() shortdate() about() execx86() lcase() shuffle() add() exit() localtime1() shufflestr() addsuffix() expand7to8() localtime2() shufflestring() appendfile() extractbigint() localtime3() simplifyfraction() appendtextfile() extractduplicates() localtime4() simplifypath() arraytolowercase() extractfirstword() localtime5() slice() arraytouppercase() extractlist() localtime6() solveknapsack() backwardshuffle() factorthis() localtime7() sortnumbers() beep() filesize() localtime8() speak() between() find() localtime9() spitbmp() bigint2bin() findchar() localtimea() spitcolorbmp() bin2hex() findhighest() localtimeb() split() bin2str() findinarray() longeststring() splitab() buildpdiffstring() findlowest() lspace() splitalong() capitalize() flipvertical() mag() splitalongdiffchar() ceil() float2str() makeinteger() splitat() ceil() floor() makepath() splitgroup() center() floor() max() splitline2() changecolor() fmod() min() splitlines() chararray2string() forceint() mod_2() splitnumbers() charset() formatdate() movecursor() splitparagraphs() charstats() formatpath() nicejoin() splitpath() chdir() forwardshuffle() nicepath() spliturl() checksum() fract() nospace() splitwords() chopint() fstr2hex() num2set() startswith() choplineafter() getabsolutepath() numberlength() startswithchar() clearab() getargint() openfileforreading() str2bin() cls() getargstring() openphotoeditor() str2float() cmp() getargvalue() pause() str2hex() collapsearray() getchar() percentageoftext() str2int() collapsespace() getcharcode() poweroftwo() str2txt() collapsewhitespace() getcommonfactor() print_safehtml() strafter() collapsewhitespace2() getconsolesize() printpowersoftwo() strbefore() collapsewhitespace3() getcurrentdirectory() printrows() strchr() color2str() getcurrentdrive() printstrptr() strfilter() commify() getdrivelist() printsubs() string2chararray() compactarray() getfilename() printtime() stringpattern() compactperl() getformdata() processquerystring() strquote() compress8to7() getkey() qsort() strxor() containsdigits() getnumbers() quotepath() suffix() countchar() getos() randombinary() sumofall() countchars() getpath() randomchar() swap() countstr() gettime() randomcolor() swapchar() cprintf() getword() randomintlist() swapchars() crc() group() randomstring() swapnum() crc16() hex() readdir() test() createcanvas() hex2bin() readdir2() textdump() createfile() hex2int() readfile() timestamp() createreversetable() hex2int2() readline() titlecase() cut() hex2int3() readlines() tobin() decode() hex2str() readtextfile() tobin16() decodeb64() hexchar() readtil() tobin8() decodecookie() hexcode() redirect() tobinunlimited() decodeinteger() hexdigitat() removeblanklines() tobinx() decodeintrange() hexdump() removeprefix() tohex() decodetext() hexint() removesuffix() tohex() decodeurl() hextime() removetail() tohexcolor() decryptchar() hr() replace() tohexlong() decryptstring() include() resetcolor() toint() demotex() indexof() reversecase() tonumber() die() insertbetweenchars() rgb() toperlstring() diff() int2str() rgb2str() tosafehtml() div_2() invertcharset() rnd() totitlecase() div_3() ip2hex() rol16() tr() div_5() is64bitos() rol32() trim() div_by_digit() isanyof() rol8() trimchar() drawbox() isbigint() ror16() truncatestr() drawrandomboxes() isbin() ror32() txt2str() drawrandomdots() isdec() ror8() uc() encode() isfilename83() rors() ucase() encodeb64() isfromcharset() round() unescape() encodeinteger() ishex() rspace() unescapestring() encodeintrange() isinteger() rtrim() updatescreen() encodetext() islc() savebmp() usetimer() encodeurl() isletter() say() writefile() encryptchar() ismatch() self() writetextfile() encryptstring() isnumber() selfpath() xchg() endswith() isreadonly() sentencecase() xcrypt() endswithchar() istext() set2num() xor() endswithslash() isuc() setbgcolor() xorstr() endwith() isutffilename() setpixel() env() joinfrom() sgi_compress() escape() joinpath() sgi_expand()

FileLibMin.pl
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()