Hacker News new | past | comments | ask | show | jobs | submit login

I suspect it's the wide range of special operators, variables and default arguments. Knowing, for example, that shift() shifts @_ by default. That <> iterates over @ARGV. That chomp chomps $_. Messing with @INC changes library search paths, etc.

Or, perhaps the syntax for dealing with elements in a somewhat deep data structure, like: push(@{$TV{$family}{kids}},"anotherkid");

Sometimes, people are just griping about regex syntax though, which seems disingenuous, since many languages use the exact same pcre expressions.

I like perl, but if it's been a while, there's definitely some back and forth with books to decipher something I wrote some time ago.




It largely depends from whom you learn. Most people google and run with the first thing google throws up and perl has many, MANY (due to its age) really shitty learning resources. Even the most popular one, the book Learning Perl, has as of its 6th edition (2013), grave flaws and miseducates newbies severely.

Some comment from the position of someone familiar with Modern Perl, which is largely what's practiced on CPAN:

> shift() shifts @_ by default

This is discouraged, precisely because it messes with @_. It has valid uses, but people tend to make sure it's clear from the code why it's used. (Mainly in OO helper stuff.)

> <> iterates over @ARGV

Almost nobody uses that, precisely because it's very unreadable. It only exists for compatibility reasons and was made to serve people used to sed/awk.

> chomp chomps $_

I haven't seen code use chomp in ages. I've never used it myself.

> Messing with @INC changes library search paths, etc.

This is rarely used as well. Mainly only when doing release engineering. It's also most often done via `use lib 'whatever';`.

    push(@{$TV{$family}{kids}},"anotherkid");
That is an outdated way to write that. In a decent modern style it would be written like this:

    push @{ $TV{ $family }{kids} }, "anotherkid";
And with a more modern Perl, this:

    push $TV{ $family }{kids}, "anotherkid";


Yes, I think the biggest issue with perl was the devil-may-care culture around it. That was far from the only issue, though. It had (has?) some gratuitous features which are bound to cause hard to find bugs, like implicit conversion of numeric strings to numbers in certain contexts. That particular feature was the reason I chose to learn python in the mid 90s, rather than perl.


> implicit conversion of numeric strings to numbers in certain contexts.

In Perl 6 at least, and to a large degree Perl 5 too, context only "causes" bugs if coders make assumptions that are invalid in Perl.

For example:

  say $foo + $bar
adds two numbers. So the context for $foo and $bar is numeric. So Perl coerces them to be numbers. If you didn't mean to add two numbers, don't use a numeric operation such as `+`.

If you want Perl 6 to make sure $foo and $bar are numbers already, then add a type to their declaration:

  my Int ($foo, $bar);


>>It largely depends from whom you learn.

In my case, when you learn :)


Your comment actually made me scroll back to the top to double check this thread was actually about Perl 6, not Perl 5!

Part of the point of Perl 6 was to address problems in the language and Larry (and/or those who wrote the original Perl 6 RFCs) considered several of the things you named to be problems.

> wide range of special operators, variables and default arguments

In Perl 6:

* The only special op I'm aware of is assignment.

* The only variables considered special are the "it" and "them" variables ($_, @_ and %_), the current match object ($/), and the current exception list ($!).

* There are still predefined variables, such as a DISTRO variable which contains an object representing the OS etc. on which Perl 6 is running, but I haven't found those problematic.

* Almost all use of default arguments in built-ins has been eliminated. The main exception I'm aware of is that subs and ops related to matching still default to operating on "it".

The Perl 5 <> op is gone.

> Or, perhaps the syntax for dealing with elements in a somewhat deep data structure, like: push(@{$TV{$family}{kids}},"anotherkid");

This would be something like this in Perl 6:

  my %TV;
  my $family = 'foo';
  push %TV{$family}<kids>, 'another'; 
> Sometimes, people are just griping about regex syntax though, which seems disingenuous, since many languages use the exact same pcre expressions.

This is talked of in Perl 6 circles as being ironic because regex syntax has been thoroughly cleaned up (and massively powered up too) in Perl 6.[1]

> I like perl, but if it's been a while, there's definitely some back and forth with books to decipher something I wrote some time ago.

One of the many downsides to Perl 6, imo, is that this back-to-the-book-oh-yeah aspect is still there -- but there's only incomplete doc and no books yet written by the likes of Larry.

[1] See, for example, https://github.com/moritz/json/blob/master/lib/JSON/Tiny/Gra...


>>Your comment actually made me scroll back to >>...check this thread was.. about Perl 6, not Perl 5!

Well, the context of the parent, and it's parent, was not Perl 6.


I'm a Perl newbie. What can you advise me to read (+exercises) to learn Perl 6?


IMHO Project Euler is a good start. There are solutions published in Perl6 to a large number of them.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: