It's that day again, my Monk Day. I'm up to 23 years on this site. Cool!

I had an idea recently that I wanted to scan the log files on the server I run to catch information about the life-cycle of customer tickets. I've written various scripts that run under crontab to create and to update a Freshdesk ticket.

As each of the scripts run, it uses the very handy Log::Log4perl module to log stuff, and they end up in log files which get rotated (so foo.log becomes foo.log.1) automatically. How big the files are, and how many backups you have are all configurable, of course. The logs contain lines like

2024/12/06 06:11:03 INFO : Create FD ticket 427993 for order 663363 .. + OK
for ticket creation, and
Update ticket 413229 to add invoice 802924 tag .. OK
(The OK at the end is just the result from the API call.) So I could set up a regexp that would do the usual capture, then add a list of terms that I should expect, then copy each capture to the variable named in the list .. but something was telling me there was a cool feature in Perl that I could use. All of those presentations from YAPC::NA and TPRC were prodding my long-term memory.

Of course! Named captures! (I wrote about this in Perl's hidden depths). I happily got the code working, and proudly pasted my clever solution here. And I got some feedback about how I could simplify my code. And then simplify it some more .. wow.

Clearly, I am *still* learning Perl, after 25+ years. That's how deep the language is, and that's how generous the Perl community is with sharing its knowledge.

"Nobody uses Perl anymore!!" Yeah, well, they should. it's an awesome language.

Alex / talexb / Toronto

For a long time, I had a link in my .sig going to Groklaw. I heard that as of December 2024, this link is dead. Still, thanks to PJ for all your work, we owe you so much. RIP Groklaw -- 2003 to 2013.

Replies are listed 'Best First'.
Re: 23 years, and an old dog learning new tricks
by cavac (Prior) on Dec 13, 2024 at 12:38 UTC