On Mon, Dec 09, 2002 at 10:27:20AM +1100, Damian Conway wrote: > Nicholas Clark complained:
Yes. :-) > No more than any of these are: > > key => "value"; > $hash{ key } > qw( unbare ); > > In each case, a sequence of \w characters is marked as a string in some way. > Sure, it's not with the traditional '...' or qq(...), but it's a "Here Be > Stryngs" > marker just the same. I don't think I'd include qw in that list, unless qq, qx, qr, m and the other "quoting" constructions go in. On Mon, Dec 09, 2002 at 12:34:52AM +0000, Kate L Pugh wrote: > Nick wrote: > >>> But barewords are not allowed under strict. So why is -bareword > >>> being allowed? > > Damian wrote: > >> Because it's not a bareword. ;-) > > Nick wrote: > > I think it's bad documentation - that last sentence should not use the > > identifier 'bareword' as its example identifier. > > I think that's the point of using that identifier - that something > which would otherwise be a bareword is magically de-bareworded by the '-'. OK. So I think I understand. Tokens that match /[A-Za-z_][A-Za-z_0-9]/ are considered barewords if they fail to be anything else. So there are at least 7 that I'm aware of: #!/usr/local/bin/perl #use warnings; use strict; package Foo; package main; sub bar { } use vars qw (%hash @array); # 1 Subroutines that have been seen bar; # 2 Packages that have been seen my $foo = Foo->can ("thing"); # 3 Left of a => %hash = (key => 'value'); # 4 Inside {} $foo = $hash{key}; # 5 perl1-ism for hashes ($foo) = keys hash; # 6 perl1-ism for arrays $foo = pop array; # 7 string negation $foo = -identifier; print "$foo\n"; # Not sure - are file handles barewords? print STDOUT ""; # Are format names? format STDOUT = Done . write; __END__ Which runs with this output. -identifier Done Nicholas Clark