3 ms·
Perl has always been really good at parsing, it's one if its strengths. In fact, you can usually distinguish people who like perl from those who don't based on
by ktRolster 11y ago
Perl has always been really good at parsing, it's one if its strengths. In fact, you can usually distinguish people who like perl from those who don't based on whether they understand regular expressions or not.
Another thing I like about perl is a lot of the standard library functions take an array of inputs, or a single value; and return an array or a single value.
- carlivar 11y agoNot sure about that, Ruby took the good parts of Perl regex parsing, such as the conditional format: var =~ /regex(match)/ With $1 and so on for each match.
- adrusi 11y agoRegular expressions are improved in perl 6, using a syntax that allows better readability through whitespace and comments (previously the x modifier) and new features that make the regular expressions more like PEG grammars.
- groovy2shoes 11y agoPerl has always been really good at enabling cargo-cult parsing -- the vast majority of "parsers" I've seen in Perl 5 have been ad-hoc, buggy, slow, and informally-specified. The nice thing about grammars as a language construct is that you get formal specification for free; this aids in understanding the parser. When it comes to parsing, grammars really are the right way to go, either as a built-in or as a library (Elisp, for example, has a few parsing libraries available in MELPA, and there's always good ol' LPeg for Lua). When all you have are regeces, there's a tendency to model a parser as a finite automaton where transitions are labeled with regex matches, but given how frequently programmers deal with extracting information from text, I think there's a solid argument for grammars or parser combinators being readily available in a language. Really, any text processing task more sophisticated than grep calls for tools more sophisticated than regular expressions.