What @. in perl?

What is the variable @. in perl?

This seems to be special, writable global, and (surprisingly) does not interpolate in double-quoted strings:

 use strict; use warnings; # Under 5.8, 5.10, 5.12, 5.14, and 5.16, # the following lines produce: @. = (3, 2, 1); # no error print "@.\n"; # "@." print @., "\n"; # "321" eval 'my @.; 1' # Can't use global @. in "my" at (eval 1) or die $@ ; # line 1, near "my @." 

I could not remember ever encountered this before, and did not see it in perlvar and perldata .

+6
source share
2 answers

perldoc perlvar states:

Perl variable names can also be a sequence of numbers or a single punctuation or control character. All of these names are reserved for specific Perl purposes;

and

Perl identifiers starting with numbers, control characters, or punctuation are freed from the consequences of declaring a package and are always forced to be in the package main ; they are also exempt from strict 'vars' errors.

You are using a reserved name. You should not count on the ability to rely on any features.

+6
source

$. - current line number (or record number) of the most recent file descriptor.

@. doesn't really matter or uses


"@." does not interpolate, but "@{.}" does.

@. reserved for future use and should not be used

+4
source

Source: https://habr.com/ru/post/918787/


All Articles