Hi all..
I have a script that read some text file in the directory...All the data inside the
text file then would be extracted into my sql, and i used foreach loop to read the
text file, the doing some loop while data are sorted..Here is my code.
================================
#!/usr/bin/perl
use DBI;
use IO::Socket;
my $path = "/home/roime/flow/";
my @folder;
my $file = ".flow";
my $dbh = DBI->connect('dbi:mysql:ayam','root','');
#Prepare the insert SQL
my $rec = $dbh->prepare("INSERT INTO t_flows(ipSrc, ipDst, pktSent, bytesSent,
startTime, endTime, srcPort, dstPort, tcpFlags, proto, tos) VALUES ('$value1',
'$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8',
'$value9', '$value10', '$value11')");
$rec->execute;
foreach my $file (@folder)
{
my $full_path = $path.$file;
open(FILE, $full_path)||die("Could not read file !");
my $file_contents = <FILE>;
close(FILE);
}
my $counter = 0;
@file_array = split(/ /, file_contents);
foreach (@file_array)
{
my $value1 = @file_array[$counter];
$counter = $counter + 1;
my $value2 = @file_array[$counter];
$counter = $counter + 1;
my $value3 = @file_array[$counter];
$counter = $counter + 1;
my $value4 = @file_array[$counter];
$counter = $counter + 1;
my $value6 = @file_array[$counter];
$counter = $counter + 1;
my $value7 = @file_array[$counter];
$counter = $counter + 1;
my $value8 = @file_array[$counter];
$counter = $counter + 1;
my $value9 = @file_array[$counter];
$counter = $counter + 1;
my $value10 = @file_array[$counter];
$counter = $counter + 1;
my $value11 = @file_array[$counter];
$counter = $counter + 1;
}
===========================
My problem is, the data from text file seems are sorted half, but it's display
nothing....I mean the range of the data are there, but the data actually disappeer....
=========================
Below are the view of my mysql database
+--------+--------+---------+-----------+-----------+---------+---------+---------+----------+-------+-----+
| ipSrc | ipDst | pktSent | bytesSent | startTime | endTime | srcPort | dstPort |
tcpFlags | proto | tos |
+--------+--------+---------+-----------+-----------+---------+---------+---------+----------+-------+-----+
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
| | | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 |
=======================================
Anybody have any ide about it?....That 's my code have a problem?...
Thanks a lot
This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>