Everyone has made a great points about Perl's true strength being 'getting stuff done.' BUT! The Computer Scientist in me wants to answer the question in a slightly different way. ;-)

Text processing can be thought of as reading, writing and matching data. Why are the reading and writing fast? I'd have to guess native bindings to standard C IO libs that can achieve the maximum native throughput with caching, buffering, etc. Why is the pattern matching so fast? ... <fade to black />

To fully understand that, you'll have to answer the question of 'What is computable?' and 'What are finite state automata (FSA/DFA/NFA)? ' Once you 'understand' that, you'll be on track to ask 'What are regular languages and how are regular expressions implemented Perl?' The jist of it: at any given time the regular expression engine is either in a match state or an unmatch state. Keep feeding it more input and that state could toggle. How do you define the 'matching states'? With regular languages of course....

Your question is pretty open ended, and I just wanted to throw some thoughts at you. ;-)

Regards,

Kurt

PS: Just to stir the pot, I'll link to this article too:

Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby, ...)

This article picks an edge case where a DFA is significantly slower than an NFA - two different ways you can implement a regular expression engine. I'm linking to this to point out that knowing what pattern you need to match could help you choose the better tool for the job.


In reply to Re: why text processing is fast in perl by whereiskurt
in thread why text processing is fast in perl by anilkumar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.