Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: problematic OO

by polypompholyx (Chaplain)
on Aug 03, 2005 at 09:17 UTC ( #480411=note: print w/replies, xml ) Need Help??


in reply to problematic OO

There are a few problems here. Mostly they seem to be to do with your understanding of what $self actually is. $self is generally a hashref, which contains your instance variables, like 'To' and 'Smtp'.

At the moment, your new method blesses an empty hashref containing no data. $self should probably contain the data you currently assign to %mail. Something like...

package PL::Mail; my $server = 'pop.dnvr.qwest.net'; sub new { my ( $class, $to ) = @_; my $self = { Smtp => $server, From => 'Postmaster', To => $to ? $to : 'devin.austin@gmail.com', }; # hashref containing instance variables return bless $self, $class; }

There are similar problems in your send method. You are also calling the send method incorrectly. You want something like...

my $obj = PL::Mail->new( $recipient ); $obj->send( subject => 'blah', comments => 'ftui' ):

Note that because you are passing these parameters to send as a list, the way you handle send's arguments needs to be something like...

my( $self, %params) = @_; $self->{ subject } = $params{ subject }; ...

Don't be too disheartened: at least you're using  strict :) I think you could do with having a look at perltoot. Also, Mail::Sendmail is so simple, I'm not sure if you really need to be writing a wrapper for it...

Replies are listed 'Best First'.
Re^2: problematic OO
by stonecolddevin (Vicar) on Aug 03, 2005 at 19:43 UTC
    It is very simple....and I had thought of trashing my wrapper until I got it to work...
    meh.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://480411]
help
Chatterbox?
[1nickt]: hm, what did I do wrong? No download link in a code secrtion of a node I just posted ...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2017-05-23 18:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?