masto.es es uno de los varios servidores independientes de Mastodon que puedes usar para participar en el fediverso.
Bienvenidos a masto.es, el mayor servidor de Mastodon para hispanohablantes de temática general. Registros limitados actualmente a invitaciones.

Administrado por:

Estadísticas del servidor:

1,9 K
usuarios activos

#perl

7 publicaciones5 participantes1 publicación hoy
Respondió en el hilo

@kittylyst @jmtd I agree that it can be readable, particularly with adequate comments which I feel are super-critical in #perl, although from experience I definitely think that perl makes it an awful lot easier to write unintelligible gibberish ;-)

Interesting that you feel that way about #python though - I typically consider that a bit better, although do you think it's because non-sw-dev types are writing python code and don't consider maintainability?

Every once in a while I'm just flabbergasted by how bad #Perl error-handling is, or at least old-style error-handling before Perl's version of exceptions started to catch on.
Like, the "messages" method of a "Mail::IMAPClient" object returns an empty list if there are no messages to fetch, but it returns undef (a scalar, not a list) if there was an error, so you can't just do "!@msgs" to check for an error, you have to do "@msgs==1&&!defined($msgs[0])". Ridiculous.
#programming

"Modern Perl" è un libro sul linguaggio perl, leggibile gratuitamente online.
Ho letto i primi capitoli e mi sembra una risorsa interessante da condividere. Ne abbiamo parlato (poco) su "Hello World", MUC amicə del GUUF.

"Perl was developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier."

#unix #unixITA #linuxITA #guufITA #guufXMPP #fedilug #perl #programming #programmingbooks #perl #helloworldxmpp

modernperlbooks.com/books/mode

www.modernperlbooks.comModern Perl: a Perl Tutorial 4e Table of Contents

#Perl @PerlWChallenge 332 Task 2: Odd Letters
#noxp
```
perl -MList::Util=all -E '
for(@ARGV){my %c; $c{$_}++ for split ""; say "$_ -> ", (all{$_%2} values %c)?"T":"F"}
' weekly perl challenge
```

#Perl @PerlWChallenge 332 Task 1: Binary Date
#noxp
```
perl -E '
say "$_ -> ", join "-", map {sprintf "%b", $_} split "-" for @ARGV
' 2025-07-26 2000-02-02 2024-12-31
```

#Perl @PerlWChallenge 331 Task 2: Buddy Strings
#noxp
```
perl -E '
for my($s,$t)(@ARGV){say"$s $t -> ",($j="$s$;$t")=~/^(.*)(.)(.*)(.)(.*)$;\1\4\3\2\5$/?"T":"F"}
' fuck fcuk love love fodo food feed feed
```

Oh my gosh, I didn't know that Matt Trout died. He was a definite "presence" in the Perl world.

The last time I interacted with him was years ago. He was trying to convince to me to get involved in taking on XS components of some CGI-related modules. I'd have rather had needles pounded into my eyes.

I always appreciated his bluntness. And his very fast, sharp intelligence.

I didn't even know he wasn't able to work much lately. Godspeed Matt.

#Perl #wetlands

shadowcat.co.uk/2025/07/09/rip

www.shadowcat.co.uk“Ripples They Cause in the World” – Shadowcat Systems Limited
Respondió a Profoundly Nerdy

@profoundlynerdy That's a purely syntactic issue. You want (...) to be parsed as the (...)[...] list slice operator, but here say gobbles it up for the say(...) function call syntax. Two solutions:

  1. say((split " ", "Foo Bar")[0])
  2. say +(split " ", "Foo Bar")[0]

(I changed split / / (which splits on single spaces) to split " " (which splits on any kind of (repeated) whitespace) because that's usually what people want. If you need " Foo Bar" to become ("", "Foo", "", "Bar"), use split / /.)

Solution #1 simply nests the syntactic structures: You have a list slice (...)[...] inside a function call say(...). Solution #2 (ab)uses the unary + operator, which is a no-op, but syntactically separates say from (, thus preventing ( from being parsed as the start of an argument list.

But if you only want to extract the first "word" (chunk of non-whitespace) from a string, you could also use say "Foo Bar" =~ /(\S+)/.

Dumb Perl question, because I'm insufficiently caffeinated, the answer isn't coming to me and my DDG-fu is failing me. Given the Perl one-liner that prints "Foo":

```
perl -E 'my @a = (split / /, "Foo Bar"); say $a[0]'
# Foo
```

How do I rewrite it so that an intermediate variable is not required? Doing `say ( ... )[0]` won't work, because `()` controls precedence, it doesn't construct an array. Can't seem to make it work I'm annoyed. 🤦

Respondió en el hilo

@philsplace @glennf @sixcolors But...because I'm a Perl guy, I stuck that in a script with backticks (a la: " my $status = ``)...then promptly ignore the $status, and end the script knowing that during the next crontab run rsync will fix it it there was an error! 😂

print "\nTransferring iCloud info from mac at $ip...";
my $status = `/volume2/\@appstore/synocli-net/bin/rsync [...]`;
print "\nResult:\n$status\n\nDone!\n";

Hah! #Perl FTW!