[root@home bin]# cat logcdr.pl 
#!/usr/bin/perl

### DRIVERS ###
use Env;

my $basedir = "/root";
$day = (localtime) [7];
my $filename = "$basedir/cdrs/call_log_$day";


$timestamp = time();
my($proto,$trash,$UID) = split(/([:@])/,$SIP_HF_FROM,3);
$SIP_HF_CALLID =~ s/([@.])//g;

if (substr($SIP_USER,0,2) eq "00") {$SIP_USER = "011" . substr($SIP_USER,2)}
if (length($SIP_USER) > 6) 
{
  if (! ((substr($SIP_USER,0,3) eq "011") or (substr($SIP_USER,0,1) eq "1"))) { $SIP_USER = "011" . $SIP_USER; }
}
open (FILE, ">>$filename");

print FILE "$timestamp,$SIP_HF_CSEQ,$SIP_HF_CALLID,$UID,$SIP_SRCIP,$SIP_USER,$SIP_HF_ROUTE\n";

close (FILE);
