Hi guys,
i have a sample of code in here.
can someone please explain to me what does this line below does...
(($this_mail) = ($this_in =~ /(.*)/gio));
you may refer to the complete source code i have attached below
Thanks in advanced...It's really urgent...can someone please help me!!!!
#!/usr/bin/perl
# create compare output file for CoIn
use Net::LDAP;
use Net::LDAP::Util qw(ldap_error_name ldap_error_text);
use Encode;
$DEBUG = 2;
$BASEDIR = "/log/sad/info/net/";
$INFILE = "$BASEDIR/test-contacts.dat";
$INFILE = "$BASEDIR/test.dat";
$NOW = `date +%Y%m%d`;
chop ($NOW);
$LOGFILE = "$BASEDIR/DP-contacts-$NOW.txt";
$ldapopts_host = "edsldap.dhl.com:389";
$ldapopts_root = "ou=users,o=dhl.com";
&Main;
sub Main
{
$conn_in = Net::LDAP->new($ldapopts_host);
die("server failed $ldapopts_host") unless $conn_in;
$mesg = $conn_in->bind(dn => $ldapopts_bind,password => $ldapopts_ps
+wd);
&Debug( 1, "Connected to destination : $ldapopts_host\t$NOW" );
open( IN, "$INFILE" );
while( $this_in = <IN> )
{
(($this_mail) = ($this_in =~ /(.*)/gio));
$this_user = $conn_in->search(base => $ldapopts_root, scope => "su
+b", filter => "(|(mail=$this_mail)(mailAlternateAddress=$this_mail))"
+, attr
s => ['uid','mail','mailalternateaddress','cn','ou']);
&Debug( 3, "Search:(|(mail=$this_mail)(mailAlternateAddress=$this_
+mail))");
if ($this_user->entries)
{
foreach $my_entry ($this_user->entries)
{
$entry_uid = $my_entry->get_value('uid');
$entry_mail = $my_entry->get_value('mail');
@all_alts = $my_entry->get_value('mailalternateaddress');
$my_alt_all = "";
foreach $entry_alt (@all_alts)
{
$my_alt_all .= $entry_alt;
$my_alt_all .= ",";
}
chop($my_alt_all);
$entry_cn = $my_entry->get_value('cn');
$entry_ou = $my_entry->get_value('ou');
&Debug( 1, "$entry_ou|$entry_uid|$entry_mail|$my_alt_all|$entr
+y_cn");
}
}
else
{
&Debug( 2, "NOT FOUND: $this_mail");
}
}
$conn_in->unbind if $conn_in;
close(IN);
}
#*****************************
# Handle DEBUG
#*****************************
sub Debug
{
local( $level, $message ) = @_;
if( $DEBUG >= $level )
{
if( open( DB, ">> $LOGFILE" ) )
{
print DB "\t" x ( $level - 1 ), $message, "\n";
print "\t" x ( $level - 1 ), $message, "\n";
close( DB );
};
};
};