Perl Programming Question:

Why are not Perls patterns regular expressions?

Tweet Share WhatsApp

Answer:

Because Perl patterns have backreferences.
A regular expression by definition must be able to determine the next state in the finite automaton without requiring any extra memory to keep around previous state. A pattern /([ab]+)c1/ requires the state machine to remember old states, and thus disqualifies such patterns as being regular expressions in the classic sense of the term.

Download Perl Programming PDF Read All 46 Perl Programming Questions
Previous QuestionNext Question
What is the output of the following Perl program?
1 $p1 = "prog1.java";
2 $p1 =~ s/(.*).java/$1.cpp/;
3 print "$p1n";
What does Perl do if you try to exploit the execve(2) race involving setuid scripts?