in reply to Re: O, the horrors of references and complex data structures
in thread O, the horrors of references and complex data structures

Note also that this won't work for variables you have declared with my as those don't use globs.

Forgive me if I'm being stupid, but when I fail to declare a variable with my, I get a compile error and my script won't run. So this technique must be even more magical than you let on :)

Some people drink from the fountain of knowledge, others just gargle.

  • Comment on Re: Re: O, the horrors of references and complex data structures

Replies are listed 'Best First'.
Re: Re: Re: O, the horrors of references and complex data structures
by davorg (Chancellor) on Feb 06, 2001 at 21:46 UTC

    Well, my isn't the only way to declare a variable and stop use strict 'vars' from complaining. Other ways include use vars, local and using fully qualified variable names (e.g. $main::foo).

    In general, the difference between package variables (that live in a typeglob) and lexical variables (which don't) is a very deep magic that lies at the heart of a thorough knowledge of Perl. I recommend a close study of the Variables section of the Camel book (3ed).

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me