Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: What does '::' mean in constructs '$::foo' and '@::foo'?

by ikegami (Patriarch)
on Oct 06, 2015 at 15:34 UTC ( [id://1143938]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What does '::' mean in constructs '$::foo' and '@::foo'?
in thread What does '::' mean in constructs '$::foo' and '@::foo'?

No. Assuming the purpose is to "defeat" use strict;, it was made obsolete by use vars qw( @foo );.

perl -e' use strict; @foo = 123; print "ok\n"; ' Global symbol "@foo" requires explicit package name at -e line 3. Execution of -e aborted due to compilation errors. $ perl -e' use strict; use vars qw( @foo ); @foo = 123; print "ok\n"; ' ok

But since strict was introduced in Perl 5.000 and vars was introduced in Perl 5.002, it's safe to say that was not the book's reason for using @::foo.

In fact, it's not obsolete. You still need to use fully qualified names to refer to variables in namespaces other than the current one.

use Data::Dumper qw( Dumper ); local $Data::Dumper::Useqq = 1; local $Data::Dumper::Sortkeys = 1; print(Dumper($data));

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found