I was a Perl programmer many years ago. I remember having a program called good.pl, as in “good morning,” that at login runs my terminal, my text editor, SVN, the browser, etc.
The 80-character line was a big deal, and with Perl, it was easy; that’s one of the reasons I really liked it.
I will examine one of my old Perl 5.* script (cw.pl) to see how easy it is for me to remember how it works.
After an initial ten seconds, when I need to erase the $var PHP syntax, I am ready. But first ask an AI what happened in the latest years by making the code more modern.
What are the most interesting changes
The AI added a lot of things, like renaming variables, new subroutines, etc. Let’s see only the most interesting one.
Added Pragmas
The script now has some use‘s at the top, Python style. Good stuff.
Improved Variable Handling
All variables are now properly declared with my. I like this. In my old script first time you access a “global” variable it was initialized (if I remember well)
New File Handling
Bareword filehandles has been replaced by lexical filehandles. I like it.
The say feature
We have a new say feature. I like it, not the name, but it’s a good addition.
The foreach “my” declarations
You can now using my in foreach declarations? I don’t remember if it was a thing years ago and I simply didn’t use it, but is a must have.
Proper file declaration error checking
# open(INPUTFILE, $temp_name) || warn "Could not open $temp_name\n";
open(my $fh, '<', $filename) or die "Could not open '$filename': $!\n";
I like the three-argument form of open.
Conclusions
It was a nice trip down memory lane. I will study modern Perl the next days, for fun.
Until next time.