At 20:05 2002.05.23, HENRY,MARK (HP-Roseville,ex1) wrote:
>All,
>
>On the following page:
>http://perl.xotechnologies.net/tutorials/Mail/mailsender.txt
>
>...is the line beginning "ref ($sender ..."  assignment of an anonymous array
>to a reference?
>
>
>Thx!
>
>Mark


new Mail::Sender create an object of that class. It returns a reference to the new 
object. This object can be a reference to an array or anything else. You should assume 
it is an object and only use the methods available in the Mail::Sender package to 
manipulate it. Assuming (or finding out) it is an array and trying to access that 
array directly will get you into trouble. So

ref ($sender = new Mail::Sender { from = '[EMAIL PROTECTED]', smtp =
     'server.location.net', boundary = 'This-is-a-mail-boundary-435427'}) or 
die("Error($sender) : $Mail::Sender::Error\n"); 

tries to create the new object. The result get assigned to the $sender variable. The 
"ref" function returns true if whatever is tested is a reference. The "or" is a 
short-circuit operator so the "die" function that prints the error message gets call 
only if the "ref" return a false result. The "ref" function is needed here because the 
new Mail::Sender returns an error code if it fails (value -1 to -12). These values are 
"True" i.e. they are not the empty string (""), 0 or undef.

In other words, try to assign a new Mail:Sender object to $sender and if it doesn't 
work, terminate the script with an error message.

For more information:

perldoc Mail::Sender
perldoc -f ref
perldoc perlboot

Hope this was helpful.

----------------------------------------------------------
Éric Beaudoin               <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to