3 ms·
A classic (hope I didn't get it wrong): print "[", +( join '', map { "-> $_" } @$_ ), "]" for @{$ref}
by ricardobeat 6y ago
A classic (hope I didn't get it wrong):
print "[", +( join '', map { "-> $_" } @$_ ), "]" for @{$ref}
- petre 6y agoThe concatenation operator is . in Perl and ~ in Raku. You could write a normal, braced foreach loop with another one inside and not use $_.
- notyourday 6y ago> print "[", +( join '', map { "-> $_" } @$_ ), "]" for @{$ref} Because computers are so slow, memory is so limited and disk space is so expensive the programmer absolutely had to write it in a single line in the most convoluted way possible? Yeah, that's definitely a language fault.
- ricardobeat 6y agoThis is pretty idiomatic Perl, and I've seen similar constructs countless times at work. You could indent the map body but it normally wouldn't be done for such a short expression. There is not much room for maneuver there if you don't want intermediate variables. And this is a quick sample, there is much, much hairier stuff to be found in real code. "Knowing the language well" is seen as a virtue for many.