use strict; use warnings; package foo; # this is how I usually do it. use fields qw(bar); # can't accomplish what I want with our vars alone. #As the answerers explained, I need a helper function to do this. # I guess using fields is a way to get the same effect with a, what do you call it, syntactic artificial sweetener... our $bar = "10\n"; no warnings 'deprecated'; #otherwise get warnings because fields uses pseudohash sub new { defined( my $self = shift) or die "no object"; $self = fields::new($self); $self->{bar} = 10; return $self; } package main; my $foo_obj = foo->new(); #print '$fooobj::bar: ' . $foo_obj::bar . "\n"; # I want this to print 10, but it's an uninitialized var. So commented out. print '$foo_obj-{bar}: ' . $foo_obj->{bar} . "\n"; #this prings 10 using fields print '$foo::bar: ' . $foo::bar . "\n"; # this prints 10 without the package name