in reply to Re^3: Use of uninitialized variables?
in thread Use of uninitialized variables?

First off, there is a difference between a package variable and a global variable. A package variable is accessible from outside the package, you just have to completely qualify the variable name. A global variable just means a variable visible everywhere within the current scope ... which means a variable declared at the start of a file (or package) is visible throughout that file.

Here's an example:

#!/usr/bin/env perl use 5.010_000; use strict; use warnings; { package MyTest; my $global = 'global variable'; our $package = 'package variable'; sub access_global { return $global } 1; } { package main; my $package_var = $MyTest::package; my $global_var = MyTest::access_global(); my $warning_var = eval { $MyTest::global }; say ">$_<" for $package_var, $global_var, $warning_var; } __END__ >package variable< >global variable< >< Name "MyTest::global" used only once: possible typo at /Users/io1/Work +space/example/package_variables.pl line 16. Use of uninitialized value $_ in concatenation (.) or string at /Users +/io1/Workspace/example/package_variables.pl line 18.

To get at a variable that is global within a package "MyTest" from outside "MyTest" you have to use a subroutine access_global()

As for the rest of your example, I suggest you use Class::Std to implement your inside-out class. There is a BUILD() method that you can use to initialize variables in non-standard ways.

Hope that helps =)


Smoothie, smoothie, hundre prosent naturlig!