Search code examples
perlparsingscriptingtext-parsingscripting-language

What do people mean when they say “Perl is very good at parsing”?


What do people mean when they say "Perl is very good at parsing"?

How is Perl any better or more powerful than other scripting languages such as Python or Ruby?


Solution

  • They mean that Perl was originally designed for processing text files and has many features that make it easy:

    • Perl has many functions for string processing: substr, index, chomp, length, grep, sort, reverse, lc, ucfirst, ...
    • Perl automatically converts between numbers and strings depending on how a value is used. (e.g. you can read the character string '100' from a file and add one to it without needing to do an string to integer conversion first)
    • Perl automatically handles conversion to and from the platform encoding (e.g. CRLF on Windows) and a logical newline ("\n") within your program.
    • Regular expressions are integrated into the syntax instead of being a separate library.
    • Perl's regular expressions are the "gold standard" for power and functionality.
    • Perl has full Unicode support.

    Python and Ruby also have good facilities for text processing. (Ruby in particular took much inspiration from Perl, much as Perl has shamelessly borrowed from many other languages.) There's little point in asking which is better. Use what you like.