in reply to Something I'd really like to know about OOP Perl.
First, the formatting of your post is poor, go read Writeup Formatting Tips. This link is displayed within the tips displayed below the node composition textbox. Read those tips.
Read perltoot, which is a fine OO tutorial and will answer most if not all of your questions.
How can I create a package that allows me to use scalars within that package that are Global to the package, but Encapsulated from the rest of the cruel mean world?
Choose any of these:
package Records_tagged; $Records_tagged::link_file = '/path/to/some/file'; # fully qualified s +calar our $link_file; # lexical scoped gl +obal use vars qw($link_file); # package scoped gl +obal
See our.
But from your code it is not clear wether you need package globals at all.
How you call the nethod new?
package Records_tagged; use strict; sub new { my $class = shift; my $self = shift; # this only makes sense with Records_tagged->ne +w(\%hash) $self->{link_file} = undef;
Are you passing in a hash reference? If not, you want to say
sub new { my $class = shift; my $self = {}; # create an anonymous hash $self->{link_file} = undef;
--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: Something I'd really like to know about OOP Perl.
by Sagacity (Monk) on Jan 10, 2007 at 23:29 UTC |