![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
On Parsing Perlby merlyn (Sage) |
on Dec 04, 2000 at 04:21 UTC ( [id://44722]=perlmeditation: print w/replies, xml ) | Need Help?? |
{from an alt.perl post I just made, reposted here to solicit feedback from fellow monks...}
Perl is extremely difficult to parse. In fact, some would say impossible. One thing that makes it difficult is the dual nature of a half dozen characters like "/". If that / is being used in a place that's expecting an operator, it's divide. If it's being used in a place that's expecting an operand, it's the beginning of a regular expression. So you have to keep track at all times of whether you're looking for an operator or an operand. "No problem", you say? Quick... for the following, play the game of "regex or divide?" Got those right? How about these? OK, and now some of your own: Got those too? How about these (same problem, different file): A little harder, eh? So now you have to parse OUTSIDE the file to get your answer. And as if that wasn't enough, let's get weird: Quick, was that last one a divide or a regex start? Why does it matter? Look at this: The first one is computing the sin of the true/false value gotten by matching " 25 ; # " against $_. Then it dies. The second one is computing the time of day divided by 25, then ignoring the comment. Starting to see the trouble? This leads people to say "the only thing which can parse Perl (the language) is perl (the binary)". Maybe not for Perl6. But for the Perl we know and can use today, certainly so. -- Randal L. Schwartz, Perl hacker
Back to
Meditations
|
|
异烟肼是什么药 | 26度穿什么衣服 | 呕心沥血是什么意思 | 哪吒妈妈叫什么 | 汕是什么意思 |
荼蘼是什么意思 | 柱镜度数是什么意思 | 老鼠爱吃什么食物 | 皮肤经常痒是什么原因 | 扁平疣是什么样子图片 |
花花世界不必当真是什么歌 | 75是什么意思 | 垂体泌乳素高是什么原因 | 2003年属羊的是什么命 | 腿毛多是什么原因 |
一九六三年属什么生肖 | 政委是干什么的 | 11月1日什么星座 | 4月28号是什么星座 | 榄仁是什么 |
梦见大蜈蚣是什么预兆hcv8jop1ns0r.cn | 255是什么意思520myf.com | 卤水是什么水hcv9jop5ns2r.cn | 大象灰是什么颜色hcv9jop6ns0r.cn | 生孩子大出血是什么原因造成的hcv9jop5ns0r.cn |
hc是胎儿的什么hcv8jop1ns6r.cn | 咽喉炎吃什么药能治好hcv8jop1ns8r.cn | 霍山黄芽属于什么茶hcv8jop8ns6r.cn | 89年蛇是什么命hcv9jop0ns3r.cn | 妈妈的弟弟的老婆叫什么imcecn.com |
盐袋子热敷有什么好处hcv9jop1ns9r.cn | 718是什么星座jingluanji.com | 怀孕吃什么宝宝会白hcv8jop5ns8r.cn | 年轻人心悸是什么原因hcv8jop1ns2r.cn | 白里透红的透是什么意思hcv8jop8ns8r.cn |
气垫是什么hcv9jop5ns5r.cn | 吃什么能增强免疫力和抵抗力hcv8jop7ns2r.cn | 嘴唇起泡是什么原因引起的hcv9jop0ns5r.cn | 什么的鼻子填词形容词hanqikai.com | 弊端是什么意思xjhesheng.com |