0

Recently I am using chilkat perl library for sending email

http://www.example-code.com/perl/smtp_simpleSend.asp

when i create new object

use chilkat();

#  The mailman object is used for sending and receiving email.
$mailman = new chilkat::CkMailMan();
$mailman->put_SmtpHost("smtp.chilkatsoft.com");
#  Set the SMTP login/password (if required)
$mailman->put_SmtpUsername("myUsername");
$mailman->put_SmtpPassword("myPassword");

when i try to print the object using Dumper method it returns nothing.

print Dumper($mailMan);
$VAR1 = bless( {}, 'chilkat::CkMailMan' );

how can we hide the data in blessed object like above?

Cœur
  • 37,241
  • 25
  • 195
  • 267
pavan
  • 334
  • 6
  • 20
  • 2
    All in all, the code of this stuff looks not very modern. The examples do not even have strict, and neither does the pm file itself. – simbabque Aug 17 '13 at 16:02
  • 2
    I wouldn't use any outside code that isn't on [CPAN](http://cpan.org). ( AFAIAC if it's not on CPAN, it doesn't exist. ) – Brad Gilbert Aug 17 '13 at 17:26

1 Answers1

6

Take a look at the code. It loads a C library (dll on Windows) with DynaLoader. The rest is only constructors. The properties (like SmptHost) are not kept in the Perl datastructure. It is just passed on to C function calls. I'm not even sure you can have several distinct objects at the same time. That's why there is nothing in the blessed hash.


You cannot just hide the data. There are no private methods in normal Perl objects. There is always a way to get to the stuff. There are object frameworks that make it harder to serialize it with Data::Dumper, but that is not the purpose of these. Take a look at Class::Std::Fast::Storable for example.

simbabque
  • 53,749
  • 8
  • 73
  • 136