Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

cat *.txt > .txt...........roy
Hi all..i have wrote a script that import from several text file into =
mysql..

 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=


#!/usr/local/bin/perl

use CGI ':standard';
use strict;
use warnings;
use DBI;

#my $dbh =3D DBI->connect("dbi:mysql:ayam","root",telekom);

#Prepare the insert SQL
my $rec =3D $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 =3D "/home/roime/flow/";
my @folder =3D <$path>;
my $file =3D ".flow";

foreach my $file (@folder)
{
my $full_path =3D $path.$file;
open(FILE, $full_path)||die("Could not read file !");
$Package::file_contents =3D <FILE>;
close(FILE);

=09
}

my @file_array =3D split($file_contents);
my @counter =3D 0;

for each my @file_array(@counter)
{
my @value1 =3D $file_array[$counter];
$counter =3D $counter + 1;
my @value2 =3D $file_array[$counter];
$counter =3D $counter + 1;
my @value3 =3D $file_array[$counter];
$counter =3D $counter + 1;
}

 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D

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?..



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.

Report this thread to moderator Post Follow-up to this message
Old Post
Roime bin Puniran
10-25-04 08:56 AM


Re: cat *.txt > .txt...........roy
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 mysq
l..
>
>  ========================================
==================================
=
>
> #!/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, bytes
Sent, startTime, endTime, srcPort, dstPort, tcpFlags, proto, tos) VALUES ('$value1',
 '$value2', '$value3', '$value4', '$value5', '$value6', '$value7', '$value8', '$valu
e9'
, '$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

Report this thread to moderator Post Follow-up to this message
Old Post
Chris Devers
10-25-04 08:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:28 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.