http://qs1969.pair.com?node_id=570898


in reply to Use of a global scalar

This is a fine moment for
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

;-)

See our. Variables declared with our aren't global.

The only global variables in perl are the 'special' variables, e.g. $_. But with these, "global" means only that the symbol is available everywhere, without any previous declaration - but the actual value accessible through that symbol is subject to localizing and aliasing.

The documentation for our stresses within the current scope - and a block boundary is a scoping boundary.

Say use vars qw($text) to have a package global, or use ${^_text} to have a really real global (the symbol is bound to the package main, though).

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Use of a global scalar
by Grey Fox (Chaplain) on Sep 03, 2006 at 05:22 UTC
    Cute, but if I read the manual I wouldn't learn such interesting uses of the perl command line. :-)

    -- Grey Fox
    Perl - Hours to learn lifetime to master.