Re: __FILE__ works as bareword
[email protected] ("Philippe Bruhat (BooK)")
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Nov 29, 2025 at 01:14:16AM -0500, Dan wrote: > On Sat, Nov 29, 2025 at 12:39 AM Jim Avera <[email protected]> wrote: > > > This may have come up before, I don't recall. Special tokens like > > __FILE__ are not interpolated if they appear in a position where a > > bareword hash key is allowed. > > > > perl -E 'my @a = (__FILE__ => 42); say $a[0];' # v5.43.2 > > >> __FILE__ > > > > Is this a bug? > > > > No; identifiers are also not resolved to subroutines or other keywords in > scope by the autoquoting fat comma. The autoquoting unary minus, of course, > has the opposite resolution (-__FILE__). And the easiest way to avoid autoquoting is to use an operator that doesn't do it: , See also: https://metacpan.org/dist/perlsecret/view/lib/perlsecret.pod#Winking-fat-comma -- Philippe Bruhat (BooK) Be careful when you take one side or the other. You could wind up in the middle. (Moral from Groo The Wanderer #33 (Epic))