From: Ronny on
By chance I found out that no error is issued on the following
program:

perl -w -e 'use strict; print(Does::Not::Exist,"\n")'

Instead, "Does::Not::Exist" is printed. Shouldn't there be a warning
about
the improper use of a bareword? Similarily, the program

perl -w -e 'use strict; system(Does::Not::Exist,"\n")'

results in the message

Can't exec "Does::Not::Exist": No such file or directory at -e line 1.

which too seems to suggest that Does::Not::Exist is simply interpreted
as string.
But when I use it like this:

perl -w -e 'use strict; print(ref(Does::Not::Exist),"\n")'

I get the more reasonable:

Bareword "Does::Not::Exist" not allowed while "strict subs" in use at -
e line 1.

Why is this bareword treated differently in these contexts?

Ronald


From: Ben Bullock on
Ronny <ro.naldfi.scher(a)gmail.com> wrote:
> By chance I found out that no error is issued on the following
> program:
>
> perl -w -e 'use strict; print(Does::Not::Exist,"\n")'
>
> Instead, "Does::Not::Exist" is printed. Shouldn't there be a warning
> about
> the improper use of a bareword?

It seems to be a bug in Perl.
From: sheinrich on
On May 7, 6:31 am, benkasminbull...(a)gmail.com (Ben Bullock) wrote:
> Ronny <ro.naldfi.sc...(a)gmail.com> wrote:
> > By chance I found out that no error is issued on the following
> > program:
>
> > perl -w -e 'use strict; print(Does::Not::Exist,"\n")'
>
> > Instead, "Does::Not::Exist" is printed. Shouldn't there be a warning
> > about
> > the improper use of a bareword?
>
> It seems to be a bug in Perl.

Even stranger:

scripts>perl -we "use strict; print(Does::Not::Exist);"
Name "Does::Not::Exist" used only once: possible typo at -e line 1.
print() on unopened filehandle Exist at -e line 1.

scripts>

From: A. Sinan Unur on
sheinrich(a)my-deja.com wrote in
news:764d756d-1678-422e-b813-7b39dedc0e3b(a)34g2000hsh.googlegroups.com:

> On May 7, 6:31 am, benkasminbull...(a)gmail.com (Ben Bullock) wrote:
>> Ronny <ro.naldfi.sc...(a)gmail.com> wrote:
>> > By chance I found out that no error is issued on the following
>> > program:
>>
>> > perl -w -e 'use strict; print(Does::Not::Exist,"\n")'
>>
>> > Instead, "Does::Not::Exist" is printed. Shouldn't there be a
>> > warning about
>> > the improper use of a bareword?
>>
>> It seems to be a bug in Perl.
>
> Even stranger:
>
> scripts>perl -we "use strict; print(Does::Not::Exist);"
> Name "Does::Not::Exist" used only once: possible typo at -e line 1.
> print() on unopened filehandle Exist at -e line 1.

Note that the issue only arises with print. In the case above,
Does::Not::Exist is being taken to refer to a bareword filehandle Exist
in the package Does::Not. It then seems like print wants to print $_ to
this filehandle.

As such, this treatment *may* be consistent with the following excerpt
from perldoc perldata:

Barewords
A word that has no other interpretation in the grammar will be treated
as if it were a quoted string. These are known as "barewords".

In the case of

print Does::Not::Exist;

there does seem to be a valid interpretation of Does::Not::Exist as a
filehandle if one assumes that $_ is printed.

That interpretation is borne out by the following script:

#!/usr/bin/perl

use strict;
use warnings;

print STDERR while $_ = shift;

__END__

Now, let's go back to

print Does::Not::Exist, "\n";

The comma between Does::Not::Exist and "\n" tells print that
Does::Not::Exist is not a filehandle.

Note the following cases:

C:\t> perl -w -Mstrict -e "print Does,Not,Exist, qq{\n}"
No comma allowed after filehandle at -e line 1.

In this case, Does has a valid interpretation as a
bareword filehandle. Thus, strict does not kick in.

C:\t> perl -w -Mstrict -e "print Does'Not'Exist, qq{\n}"
Does::Not::Exist

Note that ' and :: are equivalent, AFAIK.

C:\t> perl -w -Mstrict -e "print Does-Not-Exist, qq{\n}"
Bareword "Exist" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

Note no complaint about Does and Not. I don't know why.

C:\t> perl -w -Mstrict -e "print Does+Not+Exist, qq{\n}"
Bareword "Not" not allowed while "strict subs" in use at -e line 1.
Bareword "Exist" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

Note no complaint about Does. I don't know why.

Again, let's go back to:

C:\t> perl -w -Mstrict -e "print Does::Not::Exist, qq{\n}"
Does::Not::Exist

The comma establishes that Does::Not::Exist is not referring to
filehandle Exist in the package Does::Not.

Recall the excerpt from perldata above. Is there a valid interpretation
of Does::Not::Exist in the current grammar?

I claim that there is. The :: characters in the name establish that it
is the name of a package.

So, it is printed.

Sinan

--
A. Sinan Unur <1usa(a)llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
From: sheinrich on
On May 7, 1:45 pm, "A. Sinan Unur" <1...(a)llenroc.ude.invalid> wrote:

....
> Note the following cases:
>
> C:\t> perl -w -Mstrict -e "print Does,Not,Exist, qq{\n}"
> No comma allowed after filehandle at -e line 1.
>
> In this case, Does has a valid interpretation as a
> bareword filehandle. Thus, strict does not kick in.
>
But why is the first argument being taken here for a filehandle, in
spite of the comma, and not considered as namespace, as in your other
example?

....
>
> Again, let's go back to:
>
> C:\t> perl -w -Mstrict -e "print Does::Not::Exist, qq{\n}"
> Does::Not::Exist
>
> The comma establishes that Does::Not::Exist is not referring to
> filehandle Exist in the package Does::Not.
>

It seems like only Strings containing :: (or ' ) qualify as possible
package names.

Steffen