The reason typeglobs can be used as a reference in Perl

Sorry, maybe this is not a clear question, but I ask this because I do not like to read smth. and I don’t understand what I’m reading.

Here is a snippet from Perl Programming:

Since the way of dereferencing something always indicates which type of referent you are looking for , typeglob can be used in the same way as a reference can, despite the fact that typeglob contains several referents of different types. So $ {* main :: foo} and $ {\ $ main :: foo} have access to the same scalar variable, although the latter is more efficient.

For me, it looks like something is wrong, and it would be right if it were:

you can use typeglob instead of a scalar variable, because the link is always a scalar, and the compiler knows what you need.

The reason for reading the text of the book may suggest that the link may be something other than a scalar variable (that is, a scalar entry in a symbolic table). As soon as I saw a warning: use of array as a reference is deprecatedit seems to me that for a long time this paragraph in "Programming Perl" was significant, because the links can be not just scalars, but in the new 4th edition it simply has not changed to correspond to modern Perl.

I checked the error page for this book, but found nothing.

Is my assumption correct? If not, it would be so nice to explain where I'm wrong.

Thanks in advance.

+5
source share
3

. , , typeglob . , , , :

use strict;
use warnings;
use 5.010;

our $foo = 'scalar';
our @foo = qw(array of strings);
our %foo = (key => 'value');

say ${ *foo };                  # prints "scalar"
say ${ *foo }[0];               # prints "array"
say ${ *foo }{key};             # prints "value"

glob, , glob .

, my, typeglobs.

Sidenote: " " . : @array->[0] ( , $array[0]). ; Perl 5 , .

+15

, , typeglobs

, , glob - " , , "

. typeglob , , () (, STDOUT) - ,

, , typeglobs, , mordern perl

+1

PerlGuts - Perl.

http://www.cpan.org/authors/id/GAAS/illguts-0.09.pdf

, , , , perl , , , .

PS: You deserve praise if you want to understand - it will be good for you in the future :)

+1
source

All Articles