M
Michele Dondi
A friend of mine has just written his first japh. A thing that I
couldn't understand at first[*], and that continued puzzling for quite
a while is a small fragment of code along the lines of
sub'a{that does something}
At first I was surprised that such a beast did even parse, but now I'm
highly confident I've understood why it does, although not
*completely* sure...
Well, here it comes: in earlier versions of perl you used e.g.
C<<$pkg'var>> instead of C<<$pkg::var>>, and that syntax is still
supported for backwards compatibility, so
sub'a
should be equivalent to
sub ::a # a.k.a. main::a
right?
Still assuming that my interpretation is correct, there remains one
subtle difference:
# perl -le "sub'a{9} print a"
9
# perl -le "sub::a{9} print a"
Can't call method "sub::a" without a package or object reference at
-e line 1.
# perl -le "sub ::a{9} print a"
9
So that it seems that perl disambiguates in different ways the two
constructs...
[*] And he doesn't, either, for he just copied that bit from some
other japh.
Michele
couldn't understand at first[*], and that continued puzzling for quite
a while is a small fragment of code along the lines of
sub'a{that does something}
At first I was surprised that such a beast did even parse, but now I'm
highly confident I've understood why it does, although not
*completely* sure...
Well, here it comes: in earlier versions of perl you used e.g.
C<<$pkg'var>> instead of C<<$pkg::var>>, and that syntax is still
supported for backwards compatibility, so
sub'a
should be equivalent to
sub ::a # a.k.a. main::a
right?
Still assuming that my interpretation is correct, there remains one
subtle difference:
# perl -le "sub'a{9} print a"
9
# perl -le "sub::a{9} print a"
Can't call method "sub::a" without a package or object reference at
-e line 1.
# perl -le "sub ::a{9} print a"
9
So that it seems that perl disambiguates in different ways the two
constructs...
[*] And he doesn't, either, for he just copied that bit from some
other japh.
Michele