[23754] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5958 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 19 14:05:40 2003

Date: Fri, 19 Dec 2003 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 19 Dec 2003     Volume: 10 Number: 5958

Today's topics:
    Re: Add Files to Zip File <mikeflan@earthlink.net>
    Re: Add Files to Zip File <mikeflan@earthlink.net>
    Re: Add Files to Zip File <gnari@simnet.is>
    Re: Add Files to Zip File <mikeflan@earthlink.net>
        Adding Header to a database/csv <test@test.com>
    Re: Announcing File::Finder 0.01 (Tad McClellan)
    Re: creating a table report <rkdba@sympatico.ca>
        determine sizeof(char *) <m.biswas@invalid.addr>
    Re: determine sizeof(char *) <spamfilter@dot-app.org>
        h2xs example not working (ReaprZero)
        h2xs sample compile error <NOaehlkeSPAM@greendragonsoftware.com>
        Horrendous memory leak with TCP/IP Socket client, new t (Tim Shoppa)
    Re: How to apend 1 file to another? <jgibson@mail.arc.nasa.gov>
    Re: Is there something called text/csv database? <joe@bftsi0.UUCP>
    Re: merge a regex <noreply@gunnar.cc>
    Re: merge a regex <vervoom@hotmail.com>
    Re: MIME::Lite / Net::SMTP question (Yves Orton)
        Mysterious MySQL values (Martin Foster)
    Re: Mysterious MySQL values <spamfilter@dot-app.org>
        ODBC: Is there something called text/csv database? <test@test.com>
        Perl Compiler <fatkinson@mishmash.com>
    Re: Perl Compiler <spamfilter@dot-app.org>
    Re: Perl Compiler <dwall@fastmail.fm>
    Re: Problem with DBI MySQL (UPDATE command) <mike@no_address.tld>
    Re: Problem with DBI MySQL (UPDATE command) <xx087@freenet.carleton.ca>
    Re: Problem with DBI MySQL (UPDATE command) <trammell+usenet@hypersloth.invalid>
        redirect without meta <robin@csf.edu>
    Re: redirect without meta <spamfilter@dot-app.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 19 Dec 2003 14:07:06 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Add Files to Zip File
Message-Id: <3FE306D2.658D2584@earthlink.net>


Anno Siegel wrote:

> You are creating a new, empty archive for each file you encounter,
> discarding the one you have created before.  So your final archive
> will never contain more than one file.  Take "new Archive::Zip" out
> of the loop.

Thanks for the advice.  I think I'm getting somewhere now.

With the script below I get 8 copies of file13.doc put inside
the file.zip file.  I'm going back to the documentation to see if
I can put this thing together now.

use warnings;
use strict;

use File::Find;
use Archive::Zip;

my $dir = 'c:/Copy2';
my $zip = new Archive::Zip;

find sub {
    ( my $name = $_ ) =~ m/.*(?=\.\w{3})/;
    return if -d;
    return if /Io\.sys/;
    return if /Msdos\.sys/;
    return if /.*\.zip/i;
    print "$name - $& \n";
#    my $zip = new Archive::Zip;
    $zip->addFile('file12.doc', 'file13.doc', 'file15.doc');
    $zip->writeToFileNamed("file.zip");
} => $dir;

__END__




------------------------------

Date: Fri, 19 Dec 2003 14:10:38 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Add Files to Zip File
Message-Id: <3FE307A5.5A664E79@earthlink.net>


Anno Siegel wrote:

> You are creating a new, empty archive for each file you encounter,
> discarding the one you have created before.  So your final archive
> will never contain more than one file.  Take "new Archive::Zip" out
> of the loop.

Bingo.  The script below works.  I'll be posting some
more questions if I can't figure out why it works from
the documentation.



use warnings;
use strict;

use File::Find;
use Archive::Zip;

my $dir = 'c:/Copy2';
my $zip = new Archive::Zip;

find sub {
    ( my $name = $_ ) =~ m/.*(?=\.\w{3})/;
    return if -d;
    return if /Io\.sys/;
    return if /Msdos\.sys/;
    return if /.*\.zip/i;
    print "$name - $& \n";
#    my $zip = new Archive::Zip;
#    $zip->addFile('file12.doc', 'file13.doc', 'file15.doc');
    $zip->addFile($File::Find::name);
    $zip->writeToFileNamed("file.zip");
} => $dir;

__END__




------------------------------

Date: Fri, 19 Dec 2003 02:16:17 -0000
From: "Ragnar Hafstaš" <gnari@simnet.is>
Subject: Re: Add Files to Zip File
Message-Id: <brtn1s$5eb$1@news.simnet.is>


"Mike Flannigan" <mikeflan@earthlink.net> wrote in message
news:3FE25474.857FAC8@earthlink.net...
>
> I'm trying to modify the script below to ADD files to
> existing zip files.  This script is good at CREATING zip files
 ...
>     my $zip = new Archive::Zip;

my guess (and i mean guess) is insert here:
 $zip->read( $& . ".zip");

>     $zip->addFile($name);
>     $zip->writeToFileNamed($& . ".zip");


of course some error checks on the IO would probably
save your bacon sooner or later.

gnari




------------------------------

Date: Fri, 19 Dec 2003 18:58:57 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Add Files to Zip File
Message-Id: <3FE34B38.13460225@earthlink.net>


Mike Flannigan wrote:

> Bingo.  The script below works.  I'll be posting some
> more questions if I can't figure out why it works from
> the documentation.

One nice thing to have is the Archive::Zip::FAQ, which
I finally located.  I consulted updatezip.pl script, but
unfortunately it refers to a $zip->overwrite() function,
which apparently is no longer supported.  So the following
code does not work.  Back to the drawing board.

I hate to see that something this simple is so hard to
figure out in Perl, but I'll figure it out someday.



use strict;
use warnings;
use File::Find;
use File::Copy();
use Archive::Zip;

my $zipfile = '2003 - 4th Q.zip';
my ($group, $file, $zip, @delfile);

chdir 'C:/Perl/00IPO;

open SUBSCRIBE, "<subscribed2.txt" or die "$0: open subscribed2.txt: $!";

while ($group = <SUBSCRIBE>) {
    chomp $group;

    my $dir = 'C:/Perl/00IPO/'.$group.'/Old';

    $zip = new Archive::Zip;

    find sub {
        m/.*/;
        return if -d;
        return if /Io\.sys/;
        return if /Msdos\.sys/;
        return if /.*\.zip/i;
        print "$_ - $& - $File::Find::name \n";
        $zip->removeMember($_);
        if ( -r $_ ) {
            $zip->addFile($_);
        }
        else {
       warn "Don't know how to add $_\n";
 }

        # Now the zip is updated. Write it back via a temp file.
        exit( $zip->overwrite() ); # NO LONGER SUPPORTED

#        $zip->writeToFileNamed($zipfile);
        push @delfile, $_;
    } => $dir;

    foreach $file (@delfile) {
        print "$file\n";
    }

}

close SUBSCRIBE;

print "All done.\n";

__END__




------------------------------

Date: Fri, 19 Dec 2003 16:03:46 GMT
From: "Public Interest" <test@test.com>
Subject: Adding Header to a database/csv
Message-Id: <CjFEb.491890$0v4.21553563@bgtnsc04-news.ops.worldnet.att.net>

i have something like:
aaa, 11.11, 123456
bbb, 22.22, 122432
in a csv file

but i want it to look like
stock symbol, price, volume,
aaa, 11.11, 123456
bbb, 22.22, 122432

can i access to the csv file without reading the first line?




------------------------------

Date: Fri, 19 Dec 2003 09:55:25 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Announcing File::Finder 0.01
Message-Id: <slrnbu67rd.l43.tadmc@magna.augustmail.com>

Tore Aursand <tore@aursand.no> wrote:

> I've always thought comp.lang.perl.announce was the group for posts like
> this.


Did you notice the Newsgroups header on the original post?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 19 Dec 2003 10:28:16 -0500
From: "Ravi Krishna" <rkdba@sympatico.ca>
Subject: Re: creating a table report
Message-Id: <brv5g1$7p39l$1@ID-75254.news.uni-berlin.de>


"Bob Walton" <invalid-email@rochester.rr.com> wrote

Thanks for all the reply. It seems the best recourse is to attach
the report so that viewing of the report is left to a text editor
like notepad, wordpad which will not do line wrapping.

Thanks.

Ravi




------------------------------

Date: Fri, 19 Dec 2003 15:44:16 GMT
From: Mohun Biswas <m.biswas@invalid.addr>
Subject: determine sizeof(char *)
Message-Id: <k1FEb.86940$8y1.291956@attbi_s52>

How can I find out the size of a pointer on the current cpu architecture 
in pure (not XS) Perl?

MB



------------------------------

Date: Fri, 19 Dec 2003 15:56:28 GMT
From: Sherm Pendley <spamfilter@dot-app.org>
Subject: Re: determine sizeof(char *)
Message-Id: <McFEb.360$zC4.551360@news2.news.adelphia.net>

Mohun Biswas wrote:
> How can I find out the size of a pointer on the current cpu architecture 
> in pure (not XS) Perl?

use Config;

print $Config{'ptrsize'};

sherm--


------------------------------

Date: 19 Dec 2003 07:43:21 -0800
From: reaprzero@hotmail.com (ReaprZero)
Subject: h2xs example not working
Message-Id: <4e24098f.0312190743.7e889fb7@posting.google.com>

Sorry if I already posted this, I've had problems with my news client.

I've been trying to get the perlxstut example 1 working.

I've got a recent version of Perl (couple months old), the latest GCC,
the latest Cygwin under WinXP.

Everything works fine up until when I have to run make. I've checked
and rechecked my steps before this and it's something with just this
step. When I run make I get this:

Makefile:773: *** missing separator.  Stop.

I've searched through Google for a while and still can't find a fix
for this that works for me (a couple people seemed to know the answer
but were very vague about it). I've tried DMake but that doesnt seem
to make sense since it uses an entirely different type of makefile
with the extension .mk. I've also tried nmake but that seems to be
useless because I only have VS.NET on here and it appears to use an
older version VC++ to compile. Is there some way to get nmake working
with GCC? Or is that not what I need to use to solve this?

Thanks!
Alex


------------------------------

Date: Fri, 19 Dec 2003 09:42:21 -0500
From: "Alex" <NOaehlkeSPAM@greendragonsoftware.com>
Subject: h2xs sample compile error
Message-Id: <3fe30e50$0$4752$61fed72c@news.rcn.com>

Hi,

I'm trying to compile the first example from the perlxstut. I've redone the
steps a few times to make sure I'm following them properly but I keep
getting this problem when after trying to run make:

Makefile:773: *** missing separator.  Stop.

I'm using the latest Cygwin on WinXP with the latest GCC and a recent
version of Perl. I've tried reading into this and read some very vague
advice on what could fix this but I haven't found a definite solution that
has worked for me. Any ideas? All the steps before the make works fine from
the tutorial.

Thanks,
Alex




------------------------------

Date: 19 Dec 2003 09:04:31 -0800
From: shoppa@trailing-edge.com (Tim Shoppa)
Subject: Horrendous memory leak with TCP/IP Socket client, new to 5.8.0?
Message-Id: <bec993c8.0312190904.7339e41b@posting.google.com>

I have a simple TCP/IP Socket client that worked fine without a memory
leak
in 5.6.0.  But under 5.8.0 it leaks memory horribly.

The program, simplified and with a while(1) to make it chew memory to
the max
(the real program does something useful with the data in $bigline
and only connects once per second):

#!/usr/bin/perl
use strict;
use Socket;

my $internet_addr = inet_aton('localhost') or die "Failed to aton:
$!";
my $paddr = sockaddr_in(7001, $internet_addr) or die "failed to get
paddr: $!";

while(1) {
  socket(Server,PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die
"Socket failed: $!";
  connect (Server,$paddr) or die "Couldn't connect to remote port:
$!";
  undef $/; #Slurp all the data
  my $bigline = <Server>;
  close(Server);
}

The server is ridiculously simplistic: connect to it and it sends you
some data, then hangs up.  The server works fine without a memory leak
so I'm not showing it here.

This is linux 2.4.23, i686.  I assume that I'm doing something
horribly
wrong to cause this leak, but damned if I can see it.

Tim.


------------------------------

Date: Fri, 19 Dec 2003 09:43:57 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: How to apend 1 file to another?
Message-Id: <191220030943573917%jgibson@mail.arc.nasa.gov>

In article
<hTnEb.485841$0v4.21460202@bgtnsc04-news.ops.worldnet.att.net>, Wow
<test@test.com> wrote:

> Do I have to read file1 and do a >> to file2? Any easiler way? Perl or Shell
> scripts are both OK.
> 
> 

cat file1 >> file2


------------------------------

Date: Fri, 19 Dec 2003 08:42:15 -0800
From: "Joe \"Nuke Me Xemu\" Foster" <joe@bftsi0.UUCP>
Subject: Re: Is there something called text/csv database?
Message-Id: <1071852143.350352@news-1.nethere.net>

"Public Interest" <test@test.com> wrote in message <news:x0FEb.491801$0v4.21553255@bgtnsc04-news.ops.worldnet.att.net>...

> As I open "driver" for ODBC, there is something called "Microsoft Text
> Driver (*.txt; *.csv)"
>
> Ok, I understand that a .csv is, but I don't understand how ODBC will run
> SQL on a .csv.

Pretend those .CSVs are unindexed old-school .DBFs, but slower.
Just about any operation besides SELECT and INSERT will require
rewriting at least one entire .CSV file.  The ODBC driver will
have to contain an entire SQL engine, but sometimes that has to
be done anyway when there's no easy mapping from ODBC 'SQL' to
some DBMS' own proprietary 'SQL' mutant.

--
Joe Foster <mailto:jlfoster%40znet.com>  Sacrament R2-45 <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!




------------------------------

Date: Fri, 19 Dec 2003 15:24:35 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: merge a regex
Message-Id: <brv2cq$7kngm$1@ID-184292.news.uni-berlin.de>

JS wrote:
> I have a regex to get the hostname,msgid and client from a postfix
> log. However recently some changes were made to our logs so now the
> line that comes out could be in 2 forms:
> 
> Mar 26 14:06:48 rsl177.bcc.com Message forwarded from rsl177: 
> postfix/smtpd[38110]: 652C811B1:
> client=basilhr01b.bcc.com[168.166.43.36]
> 
> or
> 
> Dec 18 00:08:07 br01ai01 postfix/smtpd[1581100]: 237D75B: 
> client=basilhr01c.bcc.com[168.166.43.40]
> 
> For the first line I had the following regex:

> if (/from\s(\w+):.+:\s(\w+):\sclient=(.+)$/){
> 
> And for the second line I've written this regex:

> if (/(\w+)\s[^\s]*:\s(\w+):\sclient=(.+)$/){
> 
> What I'd like to do is merge the regex to catch both lines. Can
> anyone see how?

     /(\w+):?\s+\S+\s+(\w+):\s+client=(.+)$/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



------------------------------

Date: Fri, 19 Dec 2003 14:39:35 +0000
From: JS <vervoom@hotmail.com>
Subject: Re: merge a regex
Message-Id: <brv2jo$1080$1@cspc1n11.baplc.com>

Gunnar Hjalmarsson wrote:
> JS wrote:
> 
>> I have a regex to get the hostname,msgid and client from a postfix
>> log. However recently some changes were made to our logs so now the
>> line that comes out could be in 2 forms:
>>
>> Mar 26 14:06:48 rsl177.bcc.com Message forwarded from rsl177: 
>> postfix/smtpd[38110]: 652C811B1:
>> client=basilhr01b.bcc.com[168.166.43.36]
>>
>> or
>>
>> Dec 18 00:08:07 br01ai01 postfix/smtpd[1581100]: 237D75B: 
>> client=basilhr01c.bcc.com[168.166.43.40]
>>
>> For the first line I had the following regex:
> 
> 
>> if (/from\s(\w+):.+:\s(\w+):\sclient=(.+)$/){
>>
>> And for the second line I've written this regex:
> 
> 
>> if (/(\w+)\s[^\s]*:\s(\w+):\sclient=(.+)$/){
>>
>> What I'd like to do is merge the regex to catch both lines. Can
>> anyone see how?
> 
> 
>     /(\w+):?\s+\S+\s+(\w+):\s+client=(.+)$/
> 
Wow! That works. That's depressingly easy! I spent ages tring to figure 
it out!

JS.



------------------------------

Date: 19 Dec 2003 10:17:33 -0800
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: MIME::Lite / Net::SMTP question
Message-Id: <74f348f7.0312191017.1a35afb7@posting.google.com>

> Particularly errors from dataend() are not trapped. Following code from
> MIME::Lite ver 2.117):

Please upgrade. Ver 2.117 is very stale. Latest production version is
3.01, but you may find the dev release 3.01_03 is more to your taste,
especially if you are doing SMTP.

The only reason 3.01_03 isnt now called 3.02 is that I havent received
much test feedback, and ive been too busy to do it.


------------------------------

Date: 19 Dec 2003 08:18:50 -0800
From: mdfoster44@netscape.net (Martin Foster)
Subject: Mysterious MySQL values
Message-Id: <6a20f90a.0312190818.4735c9a1@posting.google.com>

Hi,

I've been trying to track down a mysterious bug in my code and it
seems to start
with MySQL returning different values for a field than what was
initially entered.

I've cut down my perl script to only show the problem part.  I've also
included the test data and the test output.

9:03am : titan : martin  333> cat test_data.cif 
data_225_2_11_gulpmin.cif
_iza_sc_Energy_eV_TO2_gulp = -128.515711

9:08am : titan : martin  336> cat testing_bug.plx
#!/usr/bin/perl
#  Perl script to read GULP optimised CIF files and add into online
database

use strict;
use DBI();
use Cwd;
use Data::Dumper;

my $dir= cwd;

# Connect to the database.
	my $dbh = DBI->connect("DBI:mysql:database=XXXX;host=localhost",
"xxxxx", "xxxxx", {'RaiseError' => 1});

# Drop tables.  And create new ones - only for testing
	eval { $dbh->do("DROP TABLE test_data") };
	print "Dropping test_data failed: $@\n" if $@;

# Create a new table 'test_data'
	$dbh->do("CREATE TABLE test_data (
		str_id INTEGER unsigned not null auto_increment,
		str_name VARCHAR(20),
		t_a int,
		gulpener float(20,20),
		primary key (str_id) )
		");

# Run over all files in directory	with File Find
	use File::Find;
	@ARGV = ('.') unless @ARGV;

# start parser
sub parser {
	return unless -f;  # skip directories, only work on actual files in
File::Find List
	my $infile = $File::Find::name;
	my $_2;
	my $text;
	my $t_a;
	my $au_id;
	my @cell;
	my $stmt1;
	my $sth;


	# Hack off starting ./
	$infile =~ s/^\.\///;
	$infile =~ s/^/$dir\//;
	print $infile, "\n";
	open INFILE, $infile or die "Shit! Couldn't open file $infile: $!\n";

# start loop of file to scan for data
	while (defined ($_2 = <INFILE>)){

		# Find file id (data_)
		if ($_2 =~ m/(data_\d+\D\d+\D\d+\D\w+.cif)/){
			my @name = split /\./, $1;
			my @name2 = split /_/, $name[0];
			$text = "$name2[1]\_$name2[2]\_$name2[3]";
			$t_a = $name2[2];
			# Insert data into table testrun
			$dbh->do("INSERT INTO test_data(str_name, t_a) VALUES (?,
?)",undef, $text, $t_a);
			$au_id = $dbh->{'mysql_insertid'}; # get the autoincrement value
for the item you just added

		}
		# get GULP energy
		if ($_2 =~ m/_iza_sc_Energy_eV_TO2_gulp
=\s+(-?([0-9]+(\.[0-9]*)?|\.[0-9]+))/){
			$cell[9] = $1;
			print "Found GULP Energy = ", $cell[9], " ";
			print "For str_id number ", $au_id, "\n";
			# Insert data
			$stmt1 = "UPDATE test_data SET gulpener = ? WHERE str_id = ?";
			$sth = $dbh->prepare($stmt1);
			$sth->execute($cell[9], $au_id);
		}
# end of while loop which scans for data
	}

# end of parser
}


# Run parser on all files from Find File
find(\&parser, @ARGV);


# Now check data in test_data
# By printing out all rows and all data !
	my $sth = $dbh->prepare("SELECT * FROM test_data");
	$sth->execute();
	my $table = $sth->fetchall_arrayref or die "$sth->errstr\n";

	my($i, $j);
	for $i ( 0 .. $#{$table} ) {
		for $j ( 0 .. $#{$table->[$i]} ) {
			print "$table->[$i][$j]\t";
		}
		print "\n";
	}

$sth->finish();


# Disconnect from the database.
$dbh->disconnect();


9:09am : titan : martin  339> perl testing_bug.plx test_data.cif 
/home/martin/DATABASE/test_data.cif
Found GULP Energy = -128.515711 For str_id number 1
1       225_2_11        2       -128.51571655273437500000

So the bug is here, the value for the energy that I am entering is
-128.515711
but MySQL is returning -128.515716552734375 !

Why is the value wrong to the sixth decimal place which should be a 1
not a 6 and why all these extra digits.

My guess is something to do with 
$stmt1 = "UPDATE test_data SET gulpener = ? WHERE str_id = ?";
$sth = $dbh->prepare($stmt1);
$sth->execute($cell[9], $au_id);

Maybe during the prepare part, which is buffered, some values are
mysteriously added from some obscure memory array.

But probably just a flaw in my code, which I can't figure out.

Cheers.
Kind regards,

Martin.


------------------------------

Date: Fri, 19 Dec 2003 16:38:25 GMT
From: Sherm Pendley <spamfilter@dot-app.org>
Subject: Re: Mysterious MySQL values
Message-Id: <5QFEb.366$zC4.559842@news2.news.adelphia.net>

Martin Foster wrote:

> So the bug is here, the value for the energy that I am entering is
> -128.515711
> but MySQL is returning -128.515716552734375 !
> 
> Why is the value wrong to the sixth decimal place which should be a 1
> not a 6 and why all these extra digits.

Short answer: Not all values that can be expressed in decimal notation 
can be exactly represented with a float.

A longer explanation can be found here:

<http://www.scit.wlv.ac.uk/cbook/chap4.fp.accuracy.html>

sherm--


------------------------------

Date: Fri, 19 Dec 2003 15:43:25 GMT
From: "Public Interest" <test@test.com>
Subject: ODBC: Is there something called text/csv database?
Message-Id: <x0FEb.491801$0v4.21553255@bgtnsc04-news.ops.worldnet.att.net>

As I open "driver" for ODBC, there is something called "Microsoft Text
Driver (*.txt; *.csv)"

Ok, I understand that a .csv is, but I don't understand how ODBC will run
SQL on a .csv.

Perl has something called DBI which means it is database independent. Can I
assume that ODBC/DBI is an interface to MySQL, Access, and CSV? Then will
DBI act the same regardless what it connects to (Text, CSV, MySQL). If so
then there is no difference between any database systems. If not so, if I
use the driver for text database, what limitations will I have? Such as can
I specify "integer, string, binary" etc for each field. How I can add
line...

Can I get a reference for all commands I can use for each database driver
under ODBC/PerlDBI?

By the way, do I connect PerlDBI to ODBC or DBI can replace ODBC?

Thank you.





------------------------------

Date: Fri, 19 Dec 2003 15:39:36 GMT
From: Fred Atkinson <fatkinson@mishmash.com>
Subject: Perl Compiler
Message-Id: <tp66uv0hd1ke66g9dbkfjqct27v5vpf1gk@4ax.com>

	Does anyone know if there is such a thing as a PERL compiler?

	If so, where can one be had?  


                                              Fred 



------------------------------

Date: Fri, 19 Dec 2003 16:00:43 GMT
From: Sherm Pendley <spamfilter@dot-app.org>
Subject: Re: Perl Compiler
Message-Id: <LgFEb.362$zC4.551760@news2.news.adelphia.net>

Fred Atkinson wrote:

> 	Does anyone know if there is such a thing as a PERL compiler?

Check here:

<http://theoryx5.uwinnipeg.ca/CPAN/data/Acme-Inline-PERL/PERL.html>

sherm--


------------------------------

Date: Fri, 19 Dec 2003 19:02:05 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Perl Compiler
Message-Id: <Xns94568EC463251dkwwashere@216.168.3.30>

Sherm Pendley <spamfilter@dot-app.org> wrote:

> Fred Atkinson wrote:
> 
>>      Does anyone know if there is such a thing as a PERL compiler?
> 
> Check here:
> 
><http://theoryx5.uwinnipeg.ca/CPAN/data/Acme-Inline-PERL/PERL.html>

Beautiful.


------------------------------

Date: Fri, 19 Dec 2003 16:31:03 GMT
From: "M" <mike@no_address.tld>
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <7JFEb.603737$Fm2.547017@attbi_s04>


"Brad" <pj_sammie@hotmail.com> wrote in message
news:2abd2946.0312182134.7bc80d57@posting.google.com...
> I am trying to update records in a MySQL table using DBI and DBD
> MySQL. I am receiving the following error:
>
> DBD::mysql::db do failed: You have an error in your SQL syntax.  Check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near '' at line 31 at script.pl line 287, <VARIABLER>
> line 17.

Error at line 31 of your statement, per the error:

Line 31 is    WHERE id=$archiveid");

Betcha $archiveid is undefined.





------------------------------

Date: 19 Dec 2003 17:08:52 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <slrnbu6c54.j4n.xx087@smeagol.ncf.ca>

Brad <pj_sammie@hotmail.com> wrote:
>  DBD::mysql::db do failed: You have an error in your SQL syntax.  Check
>  the manual that corresponds to your MySQL server version for the right
>  syntax to use near '' at line 31 at script.pl line 287, <VARIABLER>
>  line 17.
>  
>  The code where I am trying to update:
>  --------
>      #Update player data
>      $dbh->do("UPDATE archivestats SET
[...]
>      WHERE id=$archiveid");

Quote the right side of =:
       WHERE id='$archiveid'");

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


------------------------------

Date: Fri, 19 Dec 2003 18:29:27 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <slrnbu6gs7.8gg.trammell+usenet@hypersloth.el-swifto.com.invalid>

On 18 Dec 2003 21:34:32 -0800, Brad <pj_sammie@hotmail.com> wrote:
> I am trying to update records in a MySQL table using DBI and DBD
> MySQL. I am receiving the following error:
> 
> DBD::mysql::db do failed: You have an error in your SQL syntax.  Check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near '' at line 31 at script.pl line 287, <VARIABLER>
> line 17.
> 
> The code where I am trying to update:
> --------
>     #Update player data
>     $dbh->do("UPDATE archivestats SET
>     score=score+'$sqlsession[6]',
[snip]
>     crashes=crashes+$sqlsession[36],
>     totaltimeplayed=totaltimeplayed+$sqlsession[38]
>     WHERE id=$archiveid");
> --------
> 
> I have checked the MySQL syntax from the reference documentation, and
> everything looks ok (to me). Any ideas?
> 

Looks like one of your @sqlsession values is empty, e.g.
you're constructing a SQL query like:

  UPDATE archivestats SET score=score+'', ...

I've learned through experience that building variables into
SQL statements like that is a cause of great pain in the future.
You should really think about using binding variables, e.g.:

  UPDATE archivestats SET score = score + ?, ...

and then calling $dbh->do() like:

  $dbh->do($sql,{},@bindvals);

There's a fair amount on bind values in the DBI documentation.
You may also need to do some better sanity checking on the values
you're using in your UPDATE.



------------------------------

Date: Fri, 19 Dec 2003 10:48:09 -0700
From: "Robin" <robin@csf.edu>
Subject: redirect without meta
Message-Id: <brvee7$o6r$1@reader2.nmix.net>

I've been trying to redirect to an html page in a cgi script...how would one
do this wihout using a META tag in the script...?

Thanks...




------------------------------

Date: Fri, 19 Dec 2003 18:46:32 GMT
From: Sherm Pendley <spamfilter@dot-app.org>
Subject: Re: redirect without meta
Message-Id: <cIHEb.390$zC4.581778@news2.news.adelphia.net>

Robin wrote:

> I've been trying to redirect to an html page in a cgi script...how would one
> do this wihout using a META tag in the script...?

The same way you'd do it in any language: Return the appropriate HTTP 
header. Did you have a Perl question?

sherm--


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5958
***************************************


home help back first fref pref prev next nref lref last post