From 5e77893f7750cb306f72f716d77774596666441f Mon Sep 17 00:00:00 2001 From: "M.J.T. Guy" Date: Sun, 15 Jun 1997 19:27:52 +1200 Subject: [PATCH] perl4 to perl5.004 converion with debugger problem jmm@elegant.com (John Macdonald) wrote > The other issue is an annoyance rather than a stopper. As cited > in perl425traps, "stuff${'var}more stuff" is no longer > supported, only $::var and ${::var} are recognized with a > string. Changing the ' to :: means that the code is no longer > perl4 compatible. I don't want to have ongoing work on two > versions (perl4 and perl5), so the only good workaround, for > now, is to break the string into: > > "stuff" . $'var . "more stuff" > > As I said, it's an annoyance - there's lots of them in the code > and a significant proportion of the conversions to . would cause > lines that ought to be wrapped for readability purposes. > > Is there any hope of getting the $' syntax recognized within > strings? (Sigh, I'm sure it's too late for it to go into > 5.004_01, though.) I think it would be a very bad idea to retrofit this. Having single quotes which don't start quoted strings is a syntactic ambiguity nightmare. Consider soft references such as "stuff${'var'}more stuff". (I presume that's why it had to be removed.) You can avoid this problem, and not extend the lines quite as much, by explicitly including the package name: "stuff${main'var}more stuff" which works compatibly in perl4 and perl5. Attached is a suggested patch for perltrap. p5p-msgid: E0wdKJY-00010w-00@taurus.cus.cam.ac.uk --- pod/perltrap.pod | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pod/perltrap.pod b/pod/perltrap.pod index 7ba57d0..9382789 100644 --- a/pod/perltrap.pod +++ b/pod/perltrap.pod @@ -438,6 +438,12 @@ whether this should be classed as a bug or not. # perl4 prints: x=10 # perl5 prints: Can't find string terminator "'" anywhere before EOF +You can avoid this problem, and remain compatible with perl4, if you +always explicitly include the package name: + + $x = 10 ; + print "x=${main'x}\n" ; + Also see precedence traps, for parsing C<$:>. =item * BugFix -- 2.7.4