Re:Perl 5.26.0 released
by hoytech on Thursday June 01, 2017 @10:47AM
(#14460694)
In addition to what others have said, perl also directly exposes errno via $!:
Of course $! is a special dual-val so if you treat it as a string you get the nicer strerror(3) equivalent:
That said, some people prefer autodie: https://metacpan.org/pod/autodie
[ Parent
| on HN ]
Wow, interesting. The language has type coercion, and makes full use of it. I likey :D
Thanks for the example too!
It actually goes a bit beyond type coercion. Larry Wall is a linguist. The language is actually contextual. There's numeric vs. string context for scalars and scalar vs. list context for assignments and returns.
The list of features is impressive, but taken together all at once can be daunting. I think that's why there's so much distaste for it in certain camps. It's actually possible in a function to test whether the caller wants a single value or a list and adjust your return accordingly. It has anonymous functions. It has closures. It has map() and sort(), either of which apply a custom block of code to a list. You can easily write user-supplied functions that do that, too. It has dictionaries / associative arrays (called "hashes" in the community since that's how they are implemented), regular arrays, scalar values, and a number of different object systems from which to choose.