Jon Earle wrote:
> Hello,
>
> I'm a bit confused over something related to perl objects. I've
> included some snippets for reference, which are located below (I'll keep
> the relevant discussion here for clarity).
>
> A new QueuedMessage object is created with 3 parameters passed to the
> constructor. The constructor removes the first parm (a directory name)
> from the list (according to the docs for shift, that's how I interpret
> it) and places it into $this.
>From perlboot man page:
The extra parameter of method invocation
The invocation of:
Class->method(@args)
attempts to invoke subroutine "Class::method" as:
Class::method("Class", @args);
>From perlobj man page:
'A method expects its first argument to be the object (reference) or package
(string) it is being invoked on.'
So the first arg is a QueuedMessage obj/string which goes to this/self.
> An empty hash reference is then blessed
> into a class named by the directory in $this. The remaining two
remaining three
> parameters in @_ (one was removed by shift) are passed to initialize()
> (although I don't understand how initialize() becomes associated with
> $self). Within initialize(), those parms are popped off @_ and placed
> into $self and $queue_dir, leaving $id and $data_dir blank (even if @_
> still contained the three passed-in parms, $data_dir would still be
> blank).
The first arg to these methods is invisible and handled by the underlying
code.
> Obviously, I'm seriously missing a big point that will clarify what is
> going on. Can someone please offer the Clue by Four that will enable me
> to understand what is going on?
>
> Cheers!
> Jon
>
> In sendmail's qtool.pl script, you have, in add_source():
>
> $queued_message = new QueuedMessage($source_dir_name,
> $source_id,
> $data_dir_name);
>
> QueuedMessage objects are created thus:
>
> package QueuedMessage;
>
> sub new
> {
> my $this = shift;
> my $class = ref($this) || $this;
> my $self = {};
> bless $self, $class;
> $self->initialize(@_);
> return $self;
> }
>
> sub initialize
> {
> my $self = shift;
> my $queue_dir = shift;
> my $id = shift;
> my $data_dir = shift;
>
> $self->{id} = $id;
> $self->{control_file} = new ControlFile($queue_dir, $id);
> ...
> }
>
> and ControlFile objects are created thus:
>
> package ControlFile;
>
> sub new
> {
> my $this = shift;
> my $class = ref($this) || $this;
> my $self = {};
> bless $self, $class;
> $self->initialize(@_);
> return $self;
> }
>
> sub initialize
> {
> my $self = shift;
> my $queue_dir = shift;
> $self->{id} = shift;
>
> $self->{file_name} = $queue_dir . '/qf' . $self->{id};
> $self->{headers} = {};
> }
>
>
>
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (Free site for Perl/Lakers)
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs