Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^12: Thx, St. Larry, for the Beauty of Sigils

by shmem (Chancellor)
on Jul 28, 2019 at 10:46 UTC ( #11103528=note: print w/replies, xml ) Need Help??


in reply to Re^11: Thx, St. Larry, for the Beauty of Sigils
in thread Thx, St. Larry, for the Beauty of Sigils

I think this is a confusing terminology which might have made sense in the time of Perl4.

perl 4 did not have references at all. Back in those days building structures, e.g. multilevel hashes, was cumbersome. One leftover of these days is the global $SUBSEP or $; (see perlvar). References were introduced with perl5.0 which was a big step forward.

update

Regarding the block you quote from perlglossary - that's why I said To get hold of an anonymous variable beyond a single statement, its reference has to be stored in a named scalar variable..

What the paragraph doesn't mention is that anonymous variables which are created but not stored somewhere keep hanging around, unaccessible, until their scope ends, i.e. their reference count is increased at creation time. Consider:

use 5.10.0; $| = 1; # make a scalar reference (blessed for DESTROY to be triggered) say bless \do { my $x }; # anonymous scalar gone? nope! say "done"; sub DESTROY { warn "destroying $_[0]\n"; } __END__ main=SCALAR(0x55f1ce2d6450) done destroying main=SCALAR(0x55f1ce2d6450)

versus

use 5.10.0; $| = 1; { # make a scalar reference (blessed for DESTROY to be triggered) say bless \do { my $x }; } # anonymous scalar gone! say "done"; sub DESTROY { warn "destroying $_[0]\n"; } __END__ main=SCALAR(0x563bee102450) destroying main=SCALAR(0x563bee102450) done

This is arguably a bug.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11103528]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2020-06-05 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?