Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!psuvax1!news From: flee@cs.psu.edu (Felix Lee) Newsgroups: comp.lang.perl Subject: Nested quoting. (Re: suggestion for dbmopen) Message-ID: <-b7G.h5c@cs.psu.edu> Date: 1 Feb 91 11:49:28 GMT References: <281@sran84.sra.co.jp> <1991Jan29.163953.15953@convex.com> <283@sran84.sra.co.jp> <11231@jpl-devvax.JPL.NASA.GOV> Sender: news@cs.psu.edu (Usenet) Organization: Penn State Computer Science Lines: 32 Nntp-Posting-Host: dictionopolis.cs.psu.edu Larry Wall wrote: >Perl doesn't allow nested quote interpretation either, which also forces >you to make temporaries at times. I consider this to be an anti-obfuscatory >feature. Urm, how about this? $x{'hello'} = 'world'; print "$x{\"hello\"}"; Various strange constructs give various strange non-results. None of the following work: print "${x = \"${y = \\\"$z\\\"}\"}"; print "${x = \"${y = qq\\$z\\}\"}"; print "${x = \"${y = qq\$z\}\"}"; But this weird thing does: $x = 'world'; $y = 'hello'; print "${x=\"${y=${z=qq/$y/,$y=qq/$x/},$x=qq/$z/} ${z=${x=qq/$y/,$y=qq/$z/},$z=qq/$x/}\"}\n"; I'm a little dazed at how this works. I can barely reason through the sequence of execution. Marginal behavior is a wonderful thing. An almost-Perl parser that I've been sporadically working on won't accept any of the above, but it will accept print "$x{"hello"}"; which is perhaps mildly strange, but pretty natural. I'm not sure yet whether this is a feature or a bug. (It's a side-effect of having a scanner that will tokenize double-quoted strings for the parser.) -- Felix Lee flee@cs.psu.edu