[31033] in Perl-Users-Digest
Perl-Users Digest, Issue: 2278 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 16 18:09:46 2009
Date: Mon, 16 Mar 2009 15:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 16 Mar 2009 Volume: 11 Number: 2278
Today's topics:
Debian MySQL Perl DBI - connection terminates unexpect <john1949@yahoo.com>
Re: Debian MySQL Perl DBI - connection terminates unex <john1949@yahoo.com>
Re: Debian MySQL Perl DBI - connection terminates unex (Jens Thoms Toerring)
Re: Debian MySQL Perl DBI - connection terminates unex <tadmc@seesig.invalid>
Re: Debian MySQL Perl DBI - connection terminates unex <glex_no-spam@qwest-spam-no.invalid>
Re: FAQ posts <darkon.tdo@gmail.com>
help using SQLite3 in-memory databases (through DBI) <jdmuys@gmail.com>
Re: help using SQLite3 in-memory databases (through DBI <jdmuys@gmail.com>
Re: help using SQLite3 in-memory databases (through DBI <jdmuys@gmail.com>
Re: Most efficient way to do set-comparison <schaitan@gmail.com>
Re: Most efficient way to do set-comparison <ben@morrow.me.uk>
Re: regex for finding jumbled words <ced@blv-sam-01.ca.boeing.com>
Re: regex for finding jumbled words <1usa@llenroc.ude.invalid>
Using Imager module, resize before write? <jwcarlton@gmail.com>
Re: Using Imager module, resize before write? <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Mar 2009 14:00:44 -0000
From: "John" <john1949@yahoo.com>
Subject: Debian MySQL Perl DBI - connection terminates unexpectedly after 100 secs.
Message-Id: <gplm29$mdf$1@news.albasani.net>
Hi
I'm updating a MySQL table with about 2 million records. After about 100
seconds the program ends with no error message. If I use LIMIT 800000,50000
the part where it stopped is OK so the UPDATE part is OK.
Is there a time out parameter? Or am I running out of memory. Can the
memory be increased?
Regards
John
------------------------------
Date: Mon, 16 Mar 2009 16:55:29 -0000
From: "John" <john1949@yahoo.com>
Subject: Re: Debian MySQL Perl DBI - connection terminates unexpectedly after 100 secs.
Message-Id: <gpm09u$6cg$1@news.albasani.net>
"J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote in message
news:49be71fd$0$89873$815e3792@news.qwest.net...
> John wrote:
>> Hi
>>
>> I'm updating a MySQL table with about 2 million records. After about 100
>> seconds the program ends with no error message. If I use LIMIT
>> 800000,50000 the part where it stopped is OK so the UPDATE part is OK.
>>
>> Is there a time out parameter? Or am I running out of memory. Can the
>> memory be increased?
>
> Check line 24.
Line 24 says:-
our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output
socket hot
Can't see how that can affect it.
Regards
John
------------------------------
Date: 16 Mar 2009 17:24:16 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Debian MySQL Perl DBI - connection terminates unexpectedly after 100 secs.
Message-Id: <727ga0Fo7qv3U1@mid.uni-berlin.de>
John <john1949@yahoo.com> wrote:
> "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote in message
> news:49be71fd$0$89873$815e3792@news.qwest.net...
> > John wrote:
> >> I'm updating a MySQL table with about 2 million records. After about 100
> >> seconds the program ends with no error message. If I use LIMIT
> >> 800000,50000 the part where it stopped is OK so the UPDATE part is OK.
> >>
> >> Is there a time out parameter? Or am I running out of memory. Can the
> >> memory be increased?
> >
> > Check line 24.
> Line 24 says:-
> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output
> socket hot
> Can't see how that can affect it.
I rather guess it was a gentle hint that your problem description
is too vague to allow to deduce what's going wrong. But your sub-
ject line may contain a hint: it looks as if the update is done
from within a CGI script or something similar, running on a web
server. And normally there's a CPU time limit set for such scripts
to catch e.g. script that run in an endless loop. That's what I
would check for first (note: if it's not set then an OS default
limit may be used!). If you are using Apache it might be a RLimitCPU
directive. But there could also be a limit on the memory consumption
of such scripts (RLimitMEM with Apache2)... Perhaps a look at the log
files of the web server will give you some more hints.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Mon, 16 Mar 2009 13:28:09 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Debian MySQL Perl DBI - connection terminates unexpectedly after 100 secs.
Message-Id: <slrngrt6hp.b7s.tadmc@tadmc30.sbcglobal.net>
John <john1949@yahoo.com> wrote:
>
> "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid> wrote in message
> news:49be71fd$0$89873$815e3792@news.qwest.net...
>> John wrote:
>>> Hi
>>>
>>> I'm updating a MySQL table with about 2 million records. After about 100
>>> seconds the program ends with no error message. If I use LIMIT
>>> 800000,50000 the part where it stopped is OK so the UPDATE part is OK.
>>>
>>> Is there a time out parameter? Or am I running out of memory. Can the
>>> memory be increased?
>>
>> Check line 24.
>
> Line 24 says:-
>
> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output
> socket hot
>
> Can't see how that can affect it.
Check line 17.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Mon, 16 Mar 2009 10:36:29 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Debian MySQL Perl DBI - connection terminates unexpectedly after 100 secs.
Message-Id: <49be71fd$0$89873$815e3792@news.qwest.net>
John wrote:
> Hi
>
> I'm updating a MySQL table with about 2 million records. After about 100
> seconds the program ends with no error message. If I use LIMIT 800000,50000
> the part where it stopped is OK so the UPDATE part is OK.
>
> Is there a time out parameter? Or am I running out of memory. Can the
> memory be increased?
Check line 24.
------------------------------
Date: Mon, 16 Mar 2009 17:36:19 -0400
From: "darkon" <darkon.tdo@gmail.com>
Subject: Re: FAQ posts
Message-Id: <9aOdnVuU5-vOWyPUnZ2dnUVZ_oWWnZ2d@supernews.com>
"brian d foy" <brian.d.foy@gmail.com> wrote in message
news:140320090235236820%brian.d.foy@gmail.com...
> In article <xdadnfJ_d-_cCSfUnZ2dnUVZ_jWWnZ2d@supernews.com>, darkon
> <darkon.tdo@gmail.com> wrote:
>
>> Out of simple curiousity, what algorithm is used to decide which FAQ is
>> posted when? I noticed that the FAQs are posted roughly in sequence, but
>> not strictly in sequence. For example, FAQs from section 5 began to be
>> posted before all the FAQs from section 4 had been posted.
>
> The script that does it all is in the perlfaq repository:
>
> http://github.com/briandfoy/perlfaq/tree/master
>
> Roughly, there's a script that splits up the faq into individual
> questions, then the posting faq selects the one with the oldest mtime.
> Some of the answers have the same mtime so it's slightly out of order.
Ah, I see now. But there is one part of the code that confuses me. In
get_files() you do a Swchartzian transform with a grep in the middle of it:
my $time = 0;
my @files =
map { $_->[0] }
grep { $time ||= $_->[1]; $_->[1] == $time }
sort { $b->[1] <=> $a->[1] }
map { [ $_, -A $_ ] }
glob( File::Spec->catfile( $config->FAQ_DIR, "perlfaq*.txt" ) );
If I understand the grep correctly, @files ends up with only one filename in
it: the oldest file. But later, in select_faq(), you say
my @files = get_files( $config );
my $file = $files[rand @files];
I see no reason for the call to rand() unless it's just left over from an
earlier version. Maybe I'm missing something.
> It's not sophisticated, but it's also not important enough to put any
> additional thought into it. :)
Sure. It's still a nice little hack. Thanks for answering my idle
question.
------------------------------
Date: Mon, 16 Mar 2009 05:59:53 -0700 (PDT)
From: Jean-Denis Muys <jdmuys@gmail.com>
Subject: help using SQLite3 in-memory databases (through DBI)
Message-Id: <a37e1bdf-fe75-4653-83a7-f833f9914685@j35g2000yqh.googlegroups.com>
Hello,
I initially posted this in comp.lang.perl.modules, and then I realized
it may not have been the right place. I apologize for the cross
posting.
I am quite a newbie, and maybe this is easy, but I tried to google for
it for quite a long time to no avail. This may be at least partially
because it's not easy to have Google accept colons in search strings.
Anyhow, here goes:
I want to use SQLite3 from my Perl code. I use DBI, just because it's
seems the no-brainer choice.
My code uses a temporary database and works fine with a regular DBI
connect statement:
my $dbh = DBI->connect("dbi:SQLite:dbname=DBItest.db","", "",
{ RaiseError => 1, AutoCommit => 1 });
Now I want to test it with in-memory databases, that SQLite3 creates
when it is given as the database name the special string ":memory:"
my $dbh = DBI->Connect('dbi:SQLite:dbname=:memory:'); #
in-memory database
However, this doesn't work, and I crash on that connect statement
with
the following error message
Can't locate auto/DBI/Connect.al in @INC (@INC contains: /Volumes/
BLeopard/Applications/TextMate.app/Contents/SharedSupport/Bundles/
Perl.tmbundle/Support /System/Library/Perl/5.8.8/darwin-thread-
multi-2level /System/Library/Perl/5.8.8 /Library/Perl/5.8.8/darwin-
thread-multi-2level /Library/Perl/5.8.8 /Library/Perl /Network/
Library/
Perl/5.8.8/darwin-thread-multi-2level /Network/Library/Perl/5.8.8 /
Network/Library/Perl /System/Library/Perl/Extras/5.8.8/darwin-thread-
multi-2level /System/Library/Perl/Extras/5.8.8 /Library/Perl/5.8.6 /
Library/Perl/5.8.1 .) at /Volumes/Prune/DBItest.pl line 26
Again, to me the error message is rather puzzling as the exact same
code works in the case of a filename with no colons.
My hypotheses is that maybe the colons are screwing the connect
statement, since the connect statement itself uses colons as a
separator.
Either way, everything I tried failed, including silly things like
varying additional connect parameters or string delimitors.
Does DBI support in-memory SQLite3 databases? If so, how? Otherwise,
are there any alternative?
My configuration: MacOS X 10.5.6, Perl 5.8.8, DBI 1.5.2.
Many many thanks,
Jean-Denis
------------------------------
Date: Mon, 16 Mar 2009 06:42:53 -0700 (PDT)
From: Jean-Denis Muys <jdmuys@gmail.com>
Subject: Re: help using SQLite3 in-memory databases (through DBI)
Message-Id: <1d80d671-59d6-4a5c-86f7-ae28ed5cdab5@o36g2000yqh.googlegroups.com>
On Mar 16, 1:59=A0pm, Jean-Denis Muys <jdm...@gmail.com> wrote:
>
> My code uses a temporary database and works fine with a regular DBI
> connect statement:
> =A0 =A0 =A0 =A0 my $dbh =3D DBI->connect("dbi:SQLite:dbname=3DDBItest.db"=
,"", "",
> { RaiseError =3D> 1, AutoCommit =3D> 1 });
>
> Now I want to test it with in-memory databases, that SQLite3 creates
> when it is given as the database name the special string ":memory:"
>
> =A0 =A0 =A0 =A0 my $dbh =3D DBI->Connect('dbi:SQLite:dbname=3D:memory:');=
=A0 =A0 =A0 =A0#
> in-memory =A0database
>
> However, this doesn't work, and I crash on that connect statement
>
My own followup: I upgraded all my CPAN modules. DBI is now at version
1.607, and DBD::SQLite is now at 1.14.
I get exactly the same behaviour.
Also, this page on SQLite web site suggests exactly what I am doing:
http://www.sqlite.org/cvstrac/wiki?p=3DPerlNotes
So I'm still lost.
If anybody out there had an idea...
Thanks again.
J-Denis
------------------------------
Date: Mon, 16 Mar 2009 07:11:38 -0700 (PDT)
From: Jean-Denis Muys <jdmuys@gmail.com>
Subject: Re: help using SQLite3 in-memory databases (through DBI)
Message-Id: <e5122aa6-aa99-4474-864d-8cdebd5636e1@a12g2000yqm.googlegroups.com>
On Mar 16, 2:42=A0pm, Jean-Denis Muys <jdm...@gmail.com> wrote:
> On Mar 16, 1:59=A0pm, Jean-Denis Muys <jdm...@gmail.com> wrote:
> >
> > =A0 =A0 =A0 =A0 my $dbh =3D DBI->Connect('dbi:SQLite:dbname=3D:memory:'=
); =A0 =A0 =A0 =A0#
> > in-memory =A0database
>
> > However, this doesn't work, and I crash on that connect statement
>
Silly me. "Connect" should have been "connect". (lower case 'c').
I apologize for the waste of bandwidth and of your attention.
Jean-Denis
------------------------------
Date: Mon, 16 Mar 2009 07:05:54 -0700 (PDT)
From: Krishna Chaitanya <schaitan@gmail.com>
Subject: Re: Most efficient way to do set-comparison
Message-Id: <b1024ff5-28ba-4df3-b3fd-67a235474014@d19g2000prh.googlegroups.com>
Thanks, sln. I'd started to think about this problem in relation to a
larger one...namely that of how to design a constructor in the best
way in general for .pm that I write. Some of the common tasks in
constructor would involve:
1. creating hash-ref and blessing it with package name
2. populating keys and values in hash-ref with what the user supplied
(this is where this set-comparison comes of use)
3. doing other "validations" on the values of those user-supplied keys
..
..finally returning the blessed referent.
A major discussion here at my work place is - is it good to put strict
checks in new() and bail out the program if user didn't give any
options to it or gave bad options. I'm of this idea. But several
others feel the new() should be benign and when you call other
methods, it should report problem and bail out.
What would all of you say about this? Is there a general best-practice
for designing constructors?
Also, is there a cool way to create the get-set methods for the
numerous instance-attributes in my classes? Any ready-made CPAN
tricks or something??
------------------------------
Date: Mon, 16 Mar 2009 16:17:06 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Most efficient way to do set-comparison
Message-Id: <2la296-qq1.ln1@osiris.mauzo.dyndns.org>
Quoth Krishna Chaitanya <schaitan@gmail.com>:
>
> Also, is there a cool way to create the get-set methods for the
> numerous instance-attributes in my classes? Any ready-made CPAN
> tricks or something??
There are many. Look in the Class:: namespace, for example.
Many people interested in OO on Perl are moving to using Moose, so you
might want to give that a look.
Ben
------------------------------
Date: Mon, 16 Mar 2009 10:30:45 -0700 (PDT)
From: "C.DeRykuks" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: regex for finding jumbled words
Message-Id: <96f2448d-925d-4938-a9ee-2605b9e8617f@b38g2000prf.googlegroups.com>
On Mar 14, 5:29=A0pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> "C.DeRykuks" <c...@blv-sam-01.ca.boeing.com> wrote innews:5e9cf87b-bb56-4=
8f2-a1fd-ed930523f185@b38g2000prf.googlegroups.com:
>
> > On Mar 11, 2:12=A0pm, luser-ex-troll <mijo...@yahoo.com> wrote:
> >> On Mar 11, 1:00=A0pm, sso <strongsilent...@gmail.com> wrote:
>
> >> > Hi, I need help figuring out the regex that would find if a word
> >> > can be made from another word.
> >> > For example
>
> >> > apple =A0could make =A0pal, lap, leap
> >> > it could not make all or peel
>
>> ...
> Anyhow, here is a version that overcomes that deficiency. I don't think
> it would be very slow either.
Nice.
--
Charles DeRykus
------------------------------
Date: Mon, 16 Mar 2009 17:49:05 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: regex for finding jumbled words
Message-Id: <Xns9BD08C8FFF996asu1cornelledu@127.0.0.1>
"C.DeRykuks" <ced@blv-sam-01.ca.boeing.com> wrote in
news:96f2448d-925d-4938-a9ee-2605b9e8617f@b38g2000prf.googlegroups.com:
> On Mar 14, 5:29 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
>> "C.DeRykuks" <c...@blv-sam-01.ca.boeing.com> wrote
>> innews:5e9cf87b-bb56-4
> 8f2-a1fd-ed930523f185@b38g2000prf.googlegroups.com:
>>
>> > On Mar 11, 2:12 pm, luser-ex-troll <mijo...@yahoo.com> wrote:
>> >> On Mar 11, 1:00 pm, sso <strongsilent...@gmail.com> wrote:
>>
>> >> > Hi, I need help figuring out the regex that would find if a word
>> >> > can be made from another word.
>> >> > For example
>>
>> >> > apple could make pal, lap, leap
>> >> > it could not make all or peel
>>
>>> ...
>> Anyhow, here is a version that overcomes that deficiency. I don't
>> think it would be very slow either.
>
> Nice.
Thanks. Your code was the inspiration that helped me see the regex
equivalent of my earlier hash based solution.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Mon, 16 Mar 2009 02:12:32 -0700 (PDT)
From: Jason Carlton <jwcarlton@gmail.com>
Subject: Using Imager module, resize before write?
Message-Id: <651055da-6af1-4bd7-85f3-55030c8748f9@s20g2000yqh.googlegroups.com>
I'm allowing my site visitor to upload an image. I then resize it to
make it fit the dimensions.
Currently, I'm having to write the image to the server, then read it,
resize it, and rewrite it. Like this:
$picture = upload('picture');
open PIC, ">$basepath/$newpicture";
binmode (PIC);
while ($bytes = read($picture,$data,16384)) {
$length_info += $bytes;
print PIC $data;
}
close PIC;
# Resize picture
my $image = Imager->new;
$image->read(file => "$basepath/$newpicture");
$resize_pic = $image->scale(xpixels=>400, qtype => 'mixing');
$resize_pic->write(file => "$basepath/$newpicture");
It seems redundant to write it twice, and it's a waste of bandwidth
when someone uploads a 3MB picture just to have it resized to 20kb,
but I haven't been able to get it to just read the file to resize
before writing it. I thought that this would work:
$picture = upload('picture');
my $image = Imager->new;
$image->read(file => "$picture");
$resize_pic = $image->scale(xpixels=>400, qtype => 'mixing');
$resize_pic->write(file => "$basepath/$newpicture");
But it just gives me an error that "$picture" isn't found.
Any advice would be appreciated! TIA,
Jason
------------------------------
Date: Mon, 16 Mar 2009 10:32:44 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Using Imager module, resize before write?
Message-Id: <slrngrs75u.mhi.hjp-usenet2@hrunkner.hjp.at>
On 2009-03-16 09:12, Jason Carlton <jwcarlton@gmail.com> wrote:
> I'm allowing my site visitor to upload an image. I then resize it to
> make it fit the dimensions.
>
> Currently, I'm having to write the image to the server, then read it,
> resize it, and rewrite it. Like this:
>
> $picture = upload('picture');
>
> open PIC, ">$basepath/$newpicture";
> binmode (PIC);
> while ($bytes = read($picture,$data,16384)) {
> $length_info += $bytes;
> print PIC $data;
> }
> close PIC;
>
> # Resize picture
> my $image = Imager->new;
> $image->read(file => "$basepath/$newpicture");
> $resize_pic = $image->scale(xpixels=>400, qtype => 'mixing');
> $resize_pic->write(file => "$basepath/$newpicture");
>
>
> It seems redundant to write it twice,
You don't have to write the picture to a file. $image->read can read
from a file handle. So
$picture = upload('picture');
my $image = Imager->new;
$image->read(fh => $picture)
should work.
> and it's a waste of bandwidth when someone uploads a 3MB picture just
> to have it resized to 20kb, but I haven't been able to get it to just
> read the file to resize before writing it.
You can't resize a picture you don't have, so there isn't anything you
can do about it, except ask the user (nicely) to resize the pictures
before uploading them (theoretically it could be done with javascript in
the browser but I don't think JS has access to the contents of an
uploaded file).
hp
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 2278
***************************************