#ver 0.2
use Net::Telnet ();
use POSIX;
$dir = 'd:/111/';
$host = '192.168.0.66';
$port = '2300';
for (;;){
$t = new Net::Telnet (Timeout => 10, Host => $host, Port => $port);
$t->waitfor(String=>'-');
$t->print("SMDR\n");
$t->waitfor(String=>'Enter Password:');
$t->print("PCCSMDR\n");
while (<$t>) {
if ($_ =~m/^[0-3].*$/){
	if (($_ =~m/RC/) | ($_ =~m/EXT/)) {
	print $_;
	} else { 
	$filename = strftime("smdr-%Y-%m.log", localtime(time));
	$fileexpression = $dir.$filename;
    open ($fh,'>>',$fileexpression);
    print $fh $_;
    close $fh;
	}
}
} #Close While loop
}