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.  An empty hash reference is then blessed
into a class named by the directory in $this.  The remaining two
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).

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} = {};
}



-- 
Jon Earle

SAVE FARSCAPE http://www.savefarscape.com/

Vegetarian - an old Indian word meaning 'lousy hunter'.
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to