Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: (jeffa) Re: Whether to use local()

by tachyon (Chancellor)
on Mar 15, 2002 at 19:25 UTC ( [id://152060]=note: print w/replies, xml ) Need Help??


in reply to (jeffa) Re: Whether to use local()
in thread Whether to use local()

Does this snippet explain our for you jeffa ?

# comment use strict in and out # use strict; package Foo; our $global = 'global '; $not_so_global = 'not so global'; package Bar; print "Full package name: ", $Foo::global, $Foo::not_so_global, "\n"; print "No package name: ", $global, $not_so_global, "\n";

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
(jeffa) 3Re: Whether to use local()
by jeffa (Bishop) on Mar 15, 2002 at 23:11 UTC
    Ahhhh, i am starting to see now:
    • my declares a local variable which is not found in a package's symbol table
    • a local var does show up in the symbol table, but if you use strict, then you have to fully qualify the variable name (that is, prefix the package name)
    • our handles the strict vs. non-fully qualified local vars
    perrin pointed me to CPAN and the Devel::Symdump module. Here is another snippet to help explain:
    #!/usr/bin/perl #use strict; use Devel::Symdump; my $obj = Devel::Symdump->new('Foo'); print map {"$_\n"} $obj->scalars; package Foo; local $Foo::qualified; local $unqualified; our $our; my $my;
    Which (without use strict) produces this ouput :
    Foo::qualified
    Foo::our
    Foo::unqualified 
    
    If strict is turned on, then $unqualified will cause a compliation error. I think i get it now! :)

    Thank you tachyon, perrin, and also rob_au for pointing out What is it adding to my symbol table?.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-29 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found