![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
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
|
|
双子座的幸运色是什么 | 便秘用什么药效果好 | 头皮挂什么科 | 草字头加叔念什么 | 王晶为什么不娶邱淑贞 |
镇关西是什么意思 | 四大天王是什么生肖 | 尿酸高适合吃什么水果 | 紫花地丁有什么功效 | 闰月是什么意思 |
血小板太高会导致什么 | tat是什么意思 | 菠菜不能与什么一起吃 | 1919年发生了什么 | 经常手麻是什么原因 |
什么样的山峰 | 3月16日是什么星座 | 盐酸达泊西汀片是什么药 | 做完痔疮手术吃什么好 | 阴唇为什么一大一小 |
什么东西补血最快hcv8jop6ns8r.cn | 阿尔茨海默症是什么hcv9jop3ns3r.cn | 残联是什么性质的单位hcv8jop1ns6r.cn | 徐长卿是什么药hcv8jop5ns0r.cn | 透析是什么意思啊hcv7jop7ns1r.cn |
透析病人磷高了吃什么降磷hcv8jop8ns8r.cn | 吃海带有什么好处和坏处cl108k.com | 曲安奈德针治疗什么hcv9jop1ns7r.cn | 低血糖会出现什么症状hcv8jop0ns6r.cn | 舅子是什么意思hcv9jop4ns7r.cn |
磁共振和ct有什么区别hcv7jop9ns3r.cn | exm是什么意思hcv9jop4ns0r.cn | 一什么香蕉hcv8jop2ns3r.cn | 户籍地是什么hcv9jop4ns3r.cn | 鱼刺卡喉咙去医院挂什么科imcecn.com |
9月9号是什么星座hcv8jop7ns4r.cn | 怀孕的最佳时间是什么时候hcv7jop6ns3r.cn | 杨梅有什么好处hcv8jop8ns8r.cn | 放疗有什么副作用hcv9jop4ns2r.cn | 心率变异性是什么意思hcv8jop9ns9r.cn |