perl

1 readers
1 users here now

perl programming language.

founded 3 years ago
MODERATORS
1
 
 

cross-posted from: https://programming.dev/post/3619339

Hello!

I am pleased to announce a new version of my Perl One-Liners Guide ebook.

Perl has a feature rich regular expression engine, plenty of builtin modules and a thriving ecosystem. Another advantage is that Perl is more portable. This book will show examples for filtering and substitution features, field processing, using standard and third-party modules, multiple file processing, how to construct solutions that depend on multiple records, how to compare records and fields between two or more files, how to identify duplicates while maintaining input order and so on.

Links:

I would highly appreciate it if you'd let me know how you felt about this book. It could be anything from a simple thank you, pointing out a typo, mistakes in code snippets, which aspects of the book worked for you (or didn't!) and so on. Reader feedback is essential and especially so for self-published authors.

Happy learning :)

2
 
 

cross-posted from: https://lemmy.ml/post/4027414

TIL that I can use Perl's Benchmark module to time and compare the performance of different commands in an OS-agnostic way, ie as long as Perl is installed.

For example, to benchmark curl, wget and httpie you could simply run:

$ perl -MBenchmark=:all \
     -E '$cmd_wget    = sub { system("wget  https://google.com > /dev/null 2>&1") };' \
     -E '$cmd_curl    = sub { system("curl  https://google.com > /dev/null 2>&1") };' \
     -E '$cmd_httpie  = sub { system("https https://google.com > /dev/null 2>&1") };' \
     -E '$timeresult  = timethese(15, { "wget" => $cmd_wget, "curl" => $cmd_curl, "httpie" => $cmd_httpie });' \
     -E 'cmpthese($timeresult)'

which on my old T530 produces:

Benchmark: timing 15 iterations of curl, httpie, wget...

      curl:  2 wallclock secs ( 0.00 usr  0.00 sys +  0.42 cusr  0.11 csys =  0.53 CPU) @ 28.30/s (n=15)
    httpie:  8 wallclock secs ( 0.00 usr  0.01 sys +  4.63 cusr  0.79 csys =  5.43 CPU) @  2.76/s (n=15)
      wget:  3 wallclock secs ( 0.00 usr  0.00 sys +  0.53 cusr  0.19 csys =  0.72 CPU) @ 20.83/s (n=15)
    
         Rate httpie   wget   curl
httpie 2.76/s     --   -87%   -90%
wget   20.8/s   654%     --   -26%
curl   28.3/s   925%    36%     --

Very handy indeed ❤

3
 
 

I did not find anything mentioning this anywhere, but it is such a basic feature of class based programming, that I can't imagine it is not there, somewhere, somehow.

class One { method do_it {say 1} }
class Two : isa(One) { method do_it { super()->do_it; say 2} } # or so...
4
5
6
1
Perl Weekly #620 (perlweekly.com)
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
7
 
 

Perl Weekly #619

8
 
 

v6 looks like nice and my Raku skills are definitely not at the level that I would need the (albeit very nice) MoarVM stack. So is there like a list of things that have not yet been implemented in the v6-perlito module? It's also nice that it works in different languages, javascript is very optimized and Go can be bytecompiled, so if my stuff is slow with MoarVM, I could always try those others out.

9
 
 

Just wanted to say hi :DD