use strict; use warnings 'all'; use DBI; # Create the sample file open outFile, '>', 'sample.csv'; print outFile #### 'Date Time client-ip Client-hostname Partner-Name Server-hostname server-IP Recipient-Address Event-ID MSGID Priority Recipient-Report-Status total-bytes Number-Recipients Origination-Time Encryption service-Version Linked-MSGID Message-Subject Sender-Address 2005-9-10 0:0:16 GMT - - - storming - Someoneg@aol.com 1027 2433A69xxxxxxxxxxxxxxxx795006DB02DADF78@storming.Domain.name1 0 0 11927 1 2005-9-10 0:0:16 GMT 0 - c=US;a= ;p=AMSCAN;l=storming-050910000016Z-212788 Fw: Hey Ugly line expansion and re-offer EX:/O=org/OU=Site/CN=RECIPIENTS/CN=Auser - 2005-9-10 0:0:16 GMT - - - storming - c1r3ai4g@aol.com 1019 2433A690xxxxxxxxxxxxxxxx5006DB02DADF78@storming.Domain.name1 0 0 11927 1 2005-9-10 0:0:16 GMT 0 - - Fw: Hey Ugly line expansion and re-offer - - 2005-9-10 0:0:16 GMT - - - storming - c1r3ai4g@aol.com 1025 2433A6xxxxxxxxxxxxxxxx95006DB02DADF78@storming.Domain.name1 0 0 11927 1 2005-9-10 0:0:16 GMT 0 - - Fw: Hey Ugly line expansion and re-offer - - 2005-9-10 0:0:16 GMT - - - storming - c1r3ai4g@aol.com 1024 2433A690Fxxxxxxxxxxxxxxxx6795006DB02DADF78@storming.Domain.name1 0 0 11927 1 2005-9-10 0:0:16 GMT 0 - - Fw: Hey Ugly line expansion and re-offer - - 2005-9-10 0:0:17 GMT - - - storming - c1r3ai4g@aol.com 1033 2433Axxxxxxxxxxxxxxxx428E5EE4C6795006DB02DADF78@storming.Domain.name1 0 0 11927 1 2005-9-10 0:0:16 GMT 0 - - Fw: Hey Ugly line expansion and re-offer Auser@Domain.name - 2005-9-10 0:0:17 GMT - - - storming - c1r3ai4g@aol.com 1020 2433A69xxxxxxxxxxxxxxxx95006DB02DADF78@storming.Domain.name1 0 0 11927 1 2005-9-10 0:0:16 GMT 0 - - Fw: Hey Ugly line expansion and re-offer Auser@Domain.name - #### '; close outFile; # The real sample code my $dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\\t}) or die "Cannot connect: " . $DBI::errstr; my $sth = $dbh->{'csv_tables'}->{'info'} = { 'file' => 'sample.csv'}; $sth = $dbh->prepare("SELECT * FROM sample.csv") or die "Cannot prepare: " . $dbh->errstr(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); while (my $row = $sth->fetchrow_hashref) { print("$row->{'Date'}, $row->{'Time'}, $row->{'Recipient-Address'}, $row->{'Message-Subject'}, $row->{'Sender-Address'}, \n"); } $sth->finish(); $dbh->disconnect(); #### 2005-9-10, 0:0:16 GMT, Someoneg@aol.com, Fw: Hey Ugly line expansion and re-offer, EX:/O=org/OU=Site/CN=RECIPIENTS/CN=Auser, 2005-9-10, 0:0:16 GMT, c1r3ai4g@aol.com, Fw: Hey Ugly line expansion and re-offer, -, 2005-9-10, 0:0:16 GMT, c1r3ai4g@aol.com, Fw: Hey Ugly line expansion and re-offer, -, 2005-9-10, 0:0:16 GMT, c1r3ai4g@aol.com, Fw: Hey Ugly line expansion and re-offer, -, 2005-9-10, 0:0:17 GMT, c1r3ai4g@aol.com, Fw: Hey Ugly line expansion and re-offer, Auser@Domain.name, 2005-9-10, 0:0:17 GMT, c1r3ai4g@aol.com, Fw: Hey Ugly line expansion and re-offer, Auser@Domain.name,