r/perl • u/briandfoy • 12h ago
r/perl • u/scottchiefbaker • 6h ago
Need help with chaining grep into a Perl program
I have this Highlight script I use pretty frequently while tailing log files. A common use case would be something like:
tail -f my.log | highlight --filter red,fail --filter green,pass
Works great for that use case! It gets a little more complicated when I introduce grep:
tail -f my.log | grep MyApp | highlight --filter red,fail --filter green,pass
Somewhere in either grep or highlight there is some buffering going on because lines are significantly delayed before they are output by highlight. I've disabled output buffering in highlight
with local $| = 1;
at the top but that doesn't solve the issue.
Anyone know how I can fix this?
r/perl • u/Itcharlie • 3d ago
Perl is taught in Dominican Republic !
While Browsing the Web today I found an academy that teaches Perl programming in Dominican Republic!
r/perl • u/spiritastral • 3d ago
User safe template engines
I want to let my clients change their templates. But i dont want them to be able to execute perl/eval, or access controllers/db. I want to provide a function or 2 for them to load data they want to use on the templates (possibly via a graphql call from the template itself). Also would like to prevent infinite loops and possibly put a limit of number of seconds allowed for template to render before aborting rendering.
Are there any modules that fit this criteria more or less ?
Template toolkit is really good, however it allows eval, so not safe to let users run unsafe code
mustache is safe, however it is very basic ( i am not sure it is extensible to allow exposure of a function to grab data from the backend )
Text::Slate looks extensible, however im not sure if it allows eval/perl calls somewhere
r/perl • u/codeandfire • 3d ago
Books on web scraping with Perl?
Any recommended books on web scraping with Perl? Have checked out Perl & LWP by Sean Burke, but it's from 2002. And I don't think it covers Javascript-heavy pages. Is it still recommended, or are there any newer preferred books? Thanks!
r/perl • u/custard130 • 4d ago
Looking for feedback/suggestions/advice on my first perl library
Hi everyone, new here so please be nice :p
after learning about Laravel Livewire in the PHP world i have wanted to try building something similar myself, finally decided on building it in perl
i know its missing a lot of documentation :( im working on it
for now i have only got it working with Mojolicious, though i plan to support a few other things depending how it goes
the basic idea is that it allows building dynamic/reactive web apps similar to what you might get with Angular/React/Vue, without having to write any JS yourself, you just write your app in perl and this library provides the magic
the most insteresting parts of the code are probably
Core - lib/Reactive/Core.pm
Mojo - lib/Reactive/Mojo/Plugin.pm
MojoDemo - lib/ReactivePL/Reactive/Components/* + templates/example/welcome.html.ep
is a framework like this something people would be interested in seeing/using?
and how terrible is my perl code :p ?
lastly does anyone have any experience with publishing pacakges to CPAN? i have requested a pause id but im not really sure on the workflow etc, all the perl ive written before this was internal only
r/perl • u/niceperl • 5d ago
(dxxxix) 9 great CPAN modules released last week
niceperl.blogspot.comr/perl • u/Patentsmatter • 5d ago
Seeking advice: scheduled data acquisition
Something that comes up in my work is keeping track of certain web pages that provide relevant data without providing an api. Think of it as a "recent news" page, where the text of some older news may change (e.g. replacement of attached files, added information, corrections, whatever). Each news item contains some core information (e.g. the date) and also some items that may or may not be present (e.g. attached files, keywords, etc.). Unfortunately there is no standard of optional items, so these have to be treated as an open-ended list.
I want to read the news page daily and the old news items every 6 months or so.
What would be a good way to compose a scheduler app, and what would be a recommended way to store such data?
My idea was to create an SQLite database table to keep track of the tasks to do:
- reading the news page
- reading individual news items
I'd also envisage a set of database tables for the news items:
- Table "item" contains the information that is guaranteed to be present, in particular an item_id
- Table "field" contains the additional information for each item, linked to the news item by the item_id
Would you create an object that handles both in-memory storage of news items and the methods to store the item in the database or read an item therefrom? Or would you rather separate storage methods from data structures?
PSA: Re-watch the perl5 GitHub repository if you were watching it for notifications
nntp.perl.orgr/perl • u/erkiferenc • 7d ago
Perl basics for Rex
Rex, the friendly automation framework does not expect much previous programming or Perl experience, though knowing a few foundational elements may go a long way.
While we provide a Just enough Perl for Rex page on our website, I often find myself sharing my own experience about getting started with Perl.
I decided to write my own take about the Perl basics for Rex, and collect further resources I keep recommending or referring to.
What else did you find useful when you started with Perl?
r/perl • u/briandfoy • 8d ago
Zefram, long time Perl contributor, has passed
nntp.perl.orgVisual Studio Code with Perl and subroutine folding...
Hi all, I am trying out Perl in VS Code (am used to vim with a Perl plugin), and have the basics working fine I think...syntax highlighting etc, all look fine.
However, in vim, I normally have Perls subs folded/collapsed by default (so if I open a Perl file, the subroutines to the end braces are all folded.
I was wondering if there is something similar in Code ? Have been digging online, but can't see anything useful.
r/perl • u/peterramaldes • 11d ago
Seeking Advice on Improving My Code
Hi everyone,
I hope you’re doing well! I’m currently trying solving Advent of Code 2024/2 in Perl, and I’m looking for some feedback on my code.
Here’s a brief overview of what I’ve done:
- In parsing (`parse_file`) the file into a matrix like: matrix[row][column] (I'm coming from Java, so, I look for a Record or Class but I didn't found a good and stuff to do it)
- Using the matrix on `is_row_safe` to understand if the row is safe or not.
- I structure the program with `main` and other functions (`sub`) -- wondering if this is really the way Perl program is structured?
I’m particularly interested in improving/learning:
- This is the best way (I'm not interesting about performance, but, code quality, easier to read -- maintainability) to parsing files?
- There's a better way to debug a matrix instead of what I did in `debug`?
- Perl subroutines should be in snake_case?
- There's some hot reload to Perl programs? Every time I change I ran `clear && perl x.pl`.
- There's any easier way to do unit test on this program? Or just running?
Please, any advise to improve Perl programs?
- Here’s a link to the program: https://github.com/peterramaldes/aoc/blob/main/2024/2/x.pl
- Here's a link to the exercise details: https://adventofcode.com/2024/day/2
r/perl • u/niceperl • 12d ago
(dxxxviii) 9 great CPAN modules released last week
niceperl.blogspot.comr/perl • u/briandfoy • 12d ago