Why are you sending two copies of your mail to the list?

Please stop doing that -- it's a great way to get ignored.

On Mon, 25 Oct 2004, Roime bin Puniran wrote:

> Hi all..i have wrote a script that import from several text file into mysql..
> 
> ===========================================================================
> 
> #!/usr/local/bin/perl
> 
> use CGI ':standard';
> use strict;
> use warnings;
> use DBI;
> 
> #my $dbh = DBI->connect("dbi:mysql:ayam","root",telekom);
> 
> #Prepare the insert SQL
> my $rec = $Package::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;
> 
> my $path = "/home/roime/flow/";
> my @folder = <$path>;
> my $file = ".flow";
> 
> foreach my $file (@folder)
> {
>       my $full_path = $path.$file;
>       open(FILE, $full_path)||die("Could not read file !");
>       $Package::file_contents = <FILE>;
>       close(FILE);
> }
> 
>       my @file_array = split($file_contents);
>       my @counter = 0;
> 
>       for each my @file_array(@counter)
>       {
>               my @value1 = $file_array[$counter];
>               $counter = $counter + 1;
>               my @value2 = $file_array[$counter];
>               $counter = $counter + 1;
>               my @value3 = $file_array[$counter];
>               $counter = $counter + 1;
>       }
> 
> ======================================================
> 
> when i try to run it and try to transfer the data into variable and 
> from the , i got this error on my code
> 
> "Missing $ on loop variable at texttest.pl line 31."
> ....Do you guys have an opinion?..

It looks like this line is the problem:

        for each my @file_array(@counter)

That is not the way to write a `foreach` loop. Try something like:

  foreach $scalar ( @list ) { ... }

You're doing something.... starkly different. 



-- 
Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to