I have a problem but cant find it

I have a problem but cant find it

am 24.03.2008 20:21:22 von Armando Gomez

Hello all!


a friend send me a script that can make a query from a MySQL into a
HTML Page
it has an error something like this but I dont know what is wrong
the error code :

Can't find string terminator "EOUsage" anywhere before EOF at
returnatable.pl line 7.


this is the code I am using perl for windows :

#!/usr/bin/perl
use DBI;
#Get arguments from command line
($db,$table,$out_file,$user,$pass)=@ARGV;
#Check for invalid info
unless($db && $table) {
print < Usage: $0


\tUnless you specify out file, STDOUT will be used.
\t(Sending an out file of '-' will generate the same result)
\tUser and Pass are optional.

EOUsage
exit();
}
#No out file if '-'
undef $out_file if($out_file eq '-');
#Connect to the DBI using our db, user, and pass
my $dbr=DBI->connect("dbi:mysql:$db",$user,$pass,{
PrintError=>0
}) or die "Can't connect to database; $DBI::errstr\n";
#Get all the rows from our table
my $sth=$dbr->prepare("SELECT * FROM $table")
or die "Can't prepare SQL statement: $DBI::errstr\n";
#Execute our command to get the rows
$sth->execute or die "Can't execute: $DBI::errstr\n";
#Open out_file
if($out_file) {
#Don't open file until now to avoid overwritting
# in case of errors
open OUT,">$out_file" or die "Cannot open $out_file for
writting: $!\n";
}
#Header html data
$head=<

Database Summary


Data in $db:$table



EOHead
out($head);
#Print a table row for each database row
my @row;
while(@row=$sth->fetchrow_array()) {
out("\n");
}
#HTML tail info
$tail=<
" . join("",@row) . "



EOTail
#Close out_file
if($out_file) {
close OUT;
}
#Disconnect from the database
$dbr->disconnect;
#Use this sub to make it easier when using file || STDOU
sub out {
my $data=shift;
if($out_file) {
print OUT $data;
} else {
print $data;
}
}


I hope someone could help me thanks!


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org

Re: I have a problem but cant find it

am 24.03.2008 20:33:12 von Jake Peavy

------=_Part_9606_19800219.1206387192155
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 3/24/08, Armando Gomez wrote:
>
> Hello all!
>
>
> a friend send me a script that can make a query from a MySQL into a
> HTML Page
> it has an error something like this but I dont know what is wrong
> the error code :
>
> Can't find string terminator "EOUsage" anywhere before EOF at
> returnatable.pl line 7.
>
>
> this is the code I am using perl for windows :
>
> #!/usr/bin/perl
> use DBI;
> #Get arguments from command line
> ($db,$table,$out_file,$user,$pass)=@ARGV;
> #Check for invalid info
> unless($db && $table) {
> print < > Usage: $0


> \tUnless you specify out file, STDOUT will be used.
> \t(Sending an out file of '-' will generate the same result)
> \tUser and Pass are optional.
>
> EOUsage
> exit();
> }




I hope someone could help me thanks!
>

The terminator for a here-doc cannot be indented. Move EOUsage to the left.

--
-jp

You know something that would really make me applaud? A guy gets stuck in
quicksand, then sinks, then suddenly comes shooting out, riding on water
skis! How do they do that?!

deepthoughtsbyjackhandy.com

------=_Part_9606_19800219.1206387192155--

Re: I have a problem but cant find it

am 24.03.2008 23:27:01 von Baron Schwartz

Hi,

On Mon, Mar 24, 2008 at 3:33 PM, Jake Peavy wrote:
> On 3/24/08, Armando Gomez wrote:
> >
> > Hello all!
> >
> >
> > a friend send me a script that can make a query from a MySQL into a
> > HTML Page
> > it has an error something like this but I dont know what is wrong
> > the error code :
> >
> > Can't find string terminator "EOUsage" anywhere before EOF at
> > returnatable.pl line 7.
> >
> >
> > this is the code I am using perl for windows :
> >
> > #!/usr/bin/perl
> > use DBI;
> > #Get arguments from command line
> > ($db,$table,$out_file,$user,$pass)=@ARGV;
> > #Check for invalid info
> > unless($db && $table) {
> > print < > > Usage: $0


> > \tUnless you specify out file, STDOUT will be used.
> > \t(Sending an out file of '-' will generate the same result)
> > \tUser and Pass are optional.
> >
> > EOUsage
> > exit();
> > }
>
>
>
>
>
> I hope someone could help me thanks!
> >
>
> The terminator for a here-doc cannot be indented. Move EOUsage to the left.

Or change the beginning to this:

print <<" EOUsage";

(Insert the correct number of spaces/tabs so it matches the line that
terminates the here-doc).

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org