package Example;
use Moose;
use Net::LDAP;
# Options related to SSH
has [ 'host', 'user'] is => 'rw', isa => 'Str', required => 1;
has 'ldap', is => 'rw';
has 'error', is => 'rw', isa => 'Str';
# Create the SSH expect object
sub get_user {
my $self = shift;
my $user = $self->user;
my $host = $self->host;
$self->ldap(
Net::LDAP->new(
$self->host
)
);
my $mesg = $self->ldap->bind;
$mesg = $self->ldap->search( filter => "(uid=$$self-user)" );
...
}
####
sub foo {
my $arg = shift;
if (exists $arg->{'fruit'} ) {
....
}
}
foo( fruit => 'banana' );
##
##
my $ldap = Net::LDAP->new( $host );
my $self->{ldap} = $ldap;