All I wanted was an image
A few years ago, as I was updating the code for the blog, I needed to grab the first image in the post, regardless of where it was. Initially the photo was immediately after the first paragraph. However that is not always the best place for one.
I had visited some blogs where an image is showing in the teaser text. I wanted to do that. Some have the full sized image and others had a resized one with text wrap. So I began scouring the web and manuals looking for an answer.
Hour after hour was spent coming up empty handed. Several sites said use this module or that module - even a range of them. Others, including a forum answer, gave me line upon line of code.
One had a script of 22 lines which used a module of about 8000 lines that called another module of several hundred lines. About 280,000 characters to do the job. What! Another had a script that did the work okay, but was 50 lines.
Come on people, this is Perl!
For ages I tried to achieve this. It was like a major expedition in search of the Holy Grail (least it seems that way). I wandered far and wide, over mountains of programming excess and spent hours researching ancient documents relating to camels. I entered the evil and dangerous caverns of PHP, only to find little but silt. At one stage I even considered consulting the mystics of C, but resisted the temptation.
My endeavors ended in Vienna. A Perl programmer works there. He gave me one short line of code.
As you see on the homepage of the blog, it works.
Sep 19, 2016