>>>>> "HP" == Harry Putnam <rea...@newsguy.com> writes:
HP> "Uri Guttman" <u...@stemsystems.com> writes: >>>>>>> "HP" == Harry Putnam <rea...@newsguy.com> writes: >> HP> About that module Mail::Mailer. I still have lots of trouble reading HP> code or docu written in the OOp format like the docs for that module. HP> The part I'm asking about is clear enough, but I couldn't find in the HP> body of the docu, what it really meant in use. >> >> what is the OO format of the docs? no such thing. HP> Uri, I think you like to argue. sometimes. sometimes not. :) HP> Is this a new `$mailer' OBJECT? HP> $mailer = Mail::Mailer->new; yes, that is the general way to create a new object in perl. read the object docs to learn more. perldoc perl lists all the docs by category and you can see which you should read. perl OO is actually very simple. get the book 'object oriented perl' if you want even more. a bit outdated but an excellent read nonetheless. HP> And just for the record, I wasn't jamming the docs but my own HP> shortcomings. I find the notations and such of Object Oriented HP> Programming confusing... I'm still struggling with regular HP> programming. OO programming isn't really different than 'regular' (normally called procedural). it is all a case of organizing your thoughts about what you want to do and then coding up those thoughts. syntax and semantics are just the fixed way we use to tell the machine what we want to do. but it all starts in your head. a disorganized mind can't ever be a good coder. >> HP> SYNOPSIS HP> use Mail::Mailer; HP> use Mail::Mailer qw(mail); # specifies default mailer >> HP> The second one there: `use Mail::Mailer qw(mail);' >> >> do you know the meaning of the word 'default' ? :) HP> Seem obvious now... but if that is all that was meant I would expect HP> instead of HP> use Mail::Mailer qw(mail); HP> Something that indicates the part inside of qw() is a value that might HP> be different everywhere. Programmers seem to often use uppercase in HP> those kinds of places. huh? HP> use Mail::Mailer qw(YOUR_MAILER); HP> or HP> use Mail::Mailer qw(MAILER); rarely are things passed in use lines in upper case other than constants. those args are passed to the import method of the class in the use line. what it does with those args is up to the module but most use it to import sub definitions and such. since with OO coding you should never import symbols, it is sometimes used in other ways like this. HP> Could that be used to replace: >> HP> use Mail::Mailer; >> HP> #my $mailer = Mail::Mailer->new( 'sendmail', '/usr/sbin/sendmail' ) ; HP> my $mailer = Mail::Mailer->new( 'qmail' ) ; HP> #my $mailer = Mail::Mailer->new( 'smtp', 'Server' => 'outgoing.verizon.net') ; HP> [...] >> HP> With: >> HP> use Mail::Mailer qw(mail); >> HP> my $mailer = Mail::Mailer->new; HP> [...] >> >> have you tried it? HP> I did yes, but didn't understand the error it produced. I see now it HP> was just looking for a module named `mail.pm' in @INC. yes. it assumes you choose a mailer it supports already. there should be a list in the docs. HP> I also noticed that just plain: HP> use Mail::Mailer; HP> And HP> $mailer = Mail::Mailer->new; HP> (Rather than: HP> `$mailer = Mail::Mailer->new( 'sendmail', '/usr/sbin/sendmail' ) ;' HP> seems to work ok too) it has a default mailer already. you can just CHANGE the default in the use line for later new() calls. simple. again you are overthinking. the module has some variable it sets to a default mailer program. if its import method is called with an arg, it sets that variable to the default you selected. nothing more than that. it isn't deep black magic but just setting a variable in a different way. HP> $mailer->open( { HP> To => $recip, HP> From => 'rea...@reader.local.lan', HP> Subject => 'EV ' . $subj, HP> } HP> ) ; HP> print $mailer $body; HP> $mailer->close() ; HP> seems to works just fine. It somehow finds sendmail without the other HP> arguments. that means sendmail is likely the default mailer already. and maybe it searches for the path or it knows it from some other way. HP> Uri writes: >> . . . . . . . . . . . . . you are overthinking here. ... HP> I'm going to have to take that as a compliment. My usual failing is HP> the reverse.. anyone can overthink. it is when you attribute some complex power or deep dark work to something which is actually very simple. you worry about how it is done or why it works a certain way when it is just a little bit of coding you don't get. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/