Code:
print "Palindrome is $1\n"
while ($str =~ m/(?=((.+).?(??{reverse($2)})))/g);
when a string like 'sdsd' is given, the above code will give all palindromes such as 'sds' and 'dsd'
If we remove the positive look ahead assertion as below:
Code:
print "Palindrome is $1\n"
while ($str =~ m/((.+).?(??{reverse($2)}))/g);
we get the result as only 'sds' which is the first palindrome. The while loop or 'g' moderator alone will not do the work.
I was wondering what exactly this look ahead assertion is doing in this particular case?
Thanks.