Live data from Hacker News

Ask HN: Why do people consider Ruby better than Perl or vice versa?

news.ycombinator.com

31–32 of 32 posts

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#31
post #30

Earlier quoted context omitted.

A modern Perl programmer might write something much more elegant: my $x = 'Apple Carrot Banana'; my @y = $x->split(' ')->sort; if (@y > 2) { say "we've got ${\@y->size} elements!"; } else { say "insufficient elements. fail."; }

Or ever-so-slightly lighter Perl 6 version: my $x = 'Apple Carrot Banana'; my @y = $x.words.sort; if @y > 2 { say "we've got {@y.elems} elements!"; } else { say "insufficient elements. fail."; }

[deleted]

Re: Ask HN: Why do people consider Ruby better than Perl or vice versa?

#32
post #30

Earlier quoted context omitted.

A modern Perl programmer might write something much more elegant: my $x = 'Apple Carrot Banana'; my @y = $x->split(' ')->sort; if (@y > 2) { say "we've got ${\@y->size} elements!"; } else { say "insufficient elements. fail."; }

Or ever-so-slightly lighter Perl 6 version: my $x = 'Apple Carrot Banana'; my @y = $x.words.sort; if @y > 2 { say "we've got {@y.elems} elements!"; } else { say "insufficient elements. fail."; }

Ironic that the final rebuttal to "Perl looks like Java" is method chaining using periods :-) But hey, that looks very nice--glad to see Perl finally "got the dots." It's been years since I used Perl, mainly because I was squarely in the mindset of the OP. I'll have to give 6 a look.
Post reply on HN