summaryrefslogtreecommitdiff
path: root/pod/perltrap.pod
diff options
context:
space:
mode:
authorM.J.T. Guy <mjtg@cus.cam.ac.uk>1997-06-15 19:27:52 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit5e77893f7750cb306f72f716d77774596666441f (patch)
tree9d54abc3c0adf5f7b42ee25c368fd539fe4562b9 /pod/perltrap.pod
parent8dbef6988b4d46823e28b4caabe5a76ed664f7aa (diff)
downloadperl-5e77893f7750cb306f72f716d77774596666441f.tar.gz
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
Diffstat (limited to 'pod/perltrap.pod')
-rw-r--r--pod/perltrap.pod6
1 files changed, 6 insertions, 0 deletions
diff --git a/pod/perltrap.pod b/pod/perltrap.pod
index 7ba57d0c70..9382789969 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