Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Perl was 1 line vs. 100 lines in everything else, in text processing. Now it is 1 line vs. 2-3 lines that are clearer and have stricter semantics. It also has support for running oneliners straight from cli. You probably don’t want to learn it today, as it won’t make that big of a difference.


What's the 2-3 line alternative to perl you are referring to?

I find piping into python to be a lot more than 2-3 lines before I'm even ready to do any manipulation of input, which again can get quite verbose. So I'm guessing it is not python.


Ruby? It has perlisms and awkisms around, here's a stupid example:

    echo -e "foo 1\nbar 2\nbaz 3" | ruby -n -e 'BEGIN { puts "===" }; $_ =~ /^b\S+ (.*)/ and puts "#{$_.chomp.upcase} => #{$1}"; END { puts "===" }'
There's -p too, -0777 works for slurp mode, throw in -rjson to get battery-included pretty_generate, interpolation can be nicer, but $_ is not implicitly used so it can get a bit more verbose than Perl.


I meant average line ratio, not literal one-liners, apologies for confusion.


When you're talking about doing things interactively (in a shell, either directly via a terminal or indirectly via an editor) then the constant factors matter far more than the asymptotics. This has always been perl's target for optimization. That's why it has a million obscure operators that no other language has.


In my mind Perl was the Rust of the 90s. Perl evangelists were everywhere and wanted to rewrite everything in one line of Perl.




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

Search: