I'm looking to figure out all the elements I need to convert my election-results Bash script to Perl, and one of the tasks involved is dealing with XML.
In the Bash script, I'm just treating the XML as text that needs to be hacked at with
But in Perl, as in many languages I presume, there are modules to help with this.
Perl Begin recommends avoiding
XML::Simple and instead using
Now I'll have to figure out what to do with the data after Perl deals with the XML so I can turn it into the HTML I'll need later in the program.
I won't lie by saying that it is a lot easier to find recently written XML-parsing strategies for Python than it is for Perl.
I'm continuing my reading of "Learning Perl."
The book is a bit dog-eared. Some of that is from carrying it around. But some of the wear is from actually reading the book.
I'm up to Page 74. I have been taking notes in the book and underlining things that seem important.
That didn't work for me. The stopper was the "you need to do the exercises" part of the enterprise. While I had the time to do the reading, I had a lot of mental resistance to trying to hack at the exercises at the end of each chapter.
I know that doing the exercises in these books helps you "get" the concepts, but I just wasn't there yet.
Now that I'm a few chapters in, I want to start typing the book's programs into my local system, running them and playing around with them a bit. While that's less than going all in on the exercises, it's more than not touching the computer or using Perl at all.
Now is the time. I'm going to really learn to program.
I've been dabbling in programming for awhile now. I've mostly stayed within the friendly confines of the Bash shell on my local Linux system and the Linux servers on which I run various scripts and services.
I've been meaning to get deeper into real programming, whatever that is, for at least a couple of years. I would say it hasn't happened, but to a small extent it has. Now I'm ready to take the next step.
So what did happen?
A couple of years ago, I began writing little Bash scripts to automate my
rsync-driven backups. With these little one- to two-liners, I didn't have to remember the exact syntax to do the
rsync backup correctly and remember where my "exclude" file was living.
I also had trouble with screen blanking in Debian Wheezy. I finally figured out how to fix the problem with
xset, and wrote a little Bash script to automate that process.
I have also written a bunch of scripts to automate posting and create an archive of this Ode site. Among these Ode-related scripts is a local Perl program that generates an Indexette date stamp. You can copy/paste it into your post file, or call the script from within a text editor, which is what I do with Gedit.
It's still a simple two-liner, albeit with more than a dozen lines explaining what's going on.
About a year ago, I started a more complicated programming project at my day job.
So what do I do at this job? I work for a bunch of local news web sites. I push content. I create web pages in an arcane CMS. I create blogs in a common CMS (WordPress). I fix broken things and solve problems. I take things that are separate and mash them together.
The project, the thing I've wanted to do, was to script together data from various sources, more specifically election results for the nine web sites I work on.
I wanted to do it in Perl. But when I finally decided to do it, I just didn't have the chops. But I did know Bash, and I learned (or learned more) about such Unix/Linux utilities as
sed to turn my data into HTML pages I could generate with
cron and iframe into my various web sites.
Thus far I've been re-reading "Learning Perl", this time noting things that will help me in my election-results project.
I'm somewhere in the 40s in terms of pages, and I'm making notes in the book -- it's a real book, not an ebook -- in pencil.
Search and replace is pretty much a core function in Perl, so I can safely say goodbye to
Concatenation can be done with a dot (a
.) between items, so that takes care of
I would really like to pump data into an array and use Perl's
foreach to process each line.
Grasping scalars and arrays is going to be key.
I'd like to code a date stamp into the data. I've already experimented with that in Perl for my Indexette date-stamper script.
Eventually I'll need to write the results out to files on the web server. That shouldn't be too hard.