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
for ticket creation, and2024/12/06 06:11:03 INFO : Create FD ticket 427993 for order 663363 .. + 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.Update ticket 413229 to add invoice 802924 tag .. OK
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.
In reply to 23 years, and an old dog learning new tricks by talexb
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |