[25612] in Perl-Users-Digest
Perl-Users Digest, Issue: 7856 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 4 11:11:02 2005
Date: Fri, 4 Mar 2005 08:10:56 -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, 4 Mar 2005 Volume: 10 Number: 7856
Today's topics:
Re: persistant db connection <nobull@mail.com>
Re: persistant db connection <alexj@floor.ch>
Re: persistant db connection <alexj@floor.ch>
Re: persistant db connection <nobull@mail.com>
Problem with debugging utf8 data - was Re: How to NOT u <flavell@ph.gla.ac.uk>
Re: ranking texts against a white list <do-not-use@invalid.net>
Re: ranking texts against a white list <mario AT mario-online DOT com@usaquelloprimadichiocciola.invalid>
Re: ranking texts against a white list <mark.clements@kcl.ac.uk>
Re: ranking texts against a white list <1usa@llenroc.ude.invalid>
Re: ranking texts against a white list <darkon.tdo@gmail.com>
Re: Setting environment with a script <nobull@mail.com>
Re: Subroutine Function <jkeen_via_google@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 04 Mar 2005 14:01:11 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: persistant db connection
Message-Id: <d09pd6$8gf$1@sun3.bham.ac.uk>
Alexandre Jaquet wrote:
> I'm a bit confused where I should place persistant connection and I want
> my scripts useds as compiled registry scripts.
>
> I've added in my httpd.conf
>
> PerlModule Apache::DB;
Are you sure you don't mean Apache::DBI?
> I add on my startup.pl script :
>
> use strict;
> use ModPerl::Registry ();
> use Apache2 ();
> use Apache::DBI;
> use Image::Magick;
> use DBI;
> use Mail::Sender;
> use Digest::MD5 qw(md5_hex);
> use Data::Dumper;
> use POSIX;
> use CGI ();
> CGI->compile(':all');
>
> Apache::DBI->connect_on_init
> ("DBI:mysql:test:localhost",
> "username",
> "passwd",
> {
> PrintError => 1, # warn() on errors
> RaiseError => 0, # don't die on error
> AutoCommit => 1, # commit executes immediately
> }
> );
> return 1;
>
> but now how can I use it in my scripts who needs to use this connection
> ? for exemple I consider $dbh as the connection reference
I've never used connect_on_init() but usually Apache::DBI is completely
transparent. You simply call DBI->connect and Apache::DBI will
intercept the request and return a persistant connection if there is on
with matching connection information.
------------------------------
Date: Fri, 04 Mar 2005 15:16:57 +0100
From: Alexandre Jaquet <alexj@floor.ch>
Subject: Re: persistant db connection
Message-Id: <d09qkn$kpk$1@news.hispeed.ch>
Brian McCauley a écrit :
>
>
> Alexandre Jaquet wrote:
>
>> I'm a bit confused where I should place persistant connection and I
>> want my scripts useds as compiled registry scripts.
>>
>> I've added in my httpd.conf
>>
>> PerlModule Apache::DB;
>
>
> Are you sure you don't mean Apache::DBI?
>
>> I add on my startup.pl script :
>>
>> use strict;
>> use ModPerl::Registry ();
>> use Apache2 ();
>> use Apache::DBI;
>> use Image::Magick;
>> use DBI;
>> use Mail::Sender;
>> use Digest::MD5 qw(md5_hex);
>> use Data::Dumper;
>> use POSIX;
>> use CGI ();
>> CGI->compile(':all');
>>
>> Apache::DBI->connect_on_init
>> ("DBI:mysql:test:localhost",
>> "username",
>> "passwd",
>> {
>> PrintError => 1, # warn() on errors
>> RaiseError => 0, # don't die on error
>> AutoCommit => 1, # commit executes immediately
>> }
>> );
>> return 1;
>>
>> but now how can I use it in my scripts who needs to use this
>> connection ? for exemple I consider $dbh as the connection reference
>
>
> I've never used connect_on_init() but usually Apache::DBI is completely
> transparent. You simply call DBI->connect and Apache::DBI will
> intercept the request and return a persistant connection if there is on
> with matching connection information.
>
Thanks :)
------------------------------
Date: Fri, 04 Mar 2005 15:23:04 +0100
From: Alexandre Jaquet <alexj@floor.ch>
Subject: Re: persistant db connection
Message-Id: <d09r07$lb5$1@news.hispeed.ch>
Alexandre Jaquet a écrit :
> Brian McCauley a écrit :
>
>>
>>
>> Alexandre Jaquet wrote:
>>
>>> I'm a bit confused where I should place persistant connection and I
>>> want my scripts useds as compiled registry scripts.
>>>
>>> I've added in my httpd.conf
>>>
>>> PerlModule Apache::DB;
>>
>>
>>
>> Are you sure you don't mean Apache::DBI?
>>
>>> I add on my startup.pl script :
>>>
>>> use strict;
>>> use ModPerl::Registry ();
>>> use Apache2 ();
>>> use Apache::DBI;
>>> use Image::Magick;
>>> use DBI;
>>> use Mail::Sender;
>>> use Digest::MD5 qw(md5_hex);
>>> use Data::Dumper;
>>> use POSIX;
>>> use CGI ();
>>> CGI->compile(':all');
>>>
>>> Apache::DBI->connect_on_init
>>> ("DBI:mysql:test:localhost",
>>> "username",
>>> "passwd",
>>> {
>>> PrintError => 1, # warn() on errors
>>> RaiseError => 0, # don't die on error
>>> AutoCommit => 1, # commit executes immediately
>>> }
>>> );
>>> return 1;
>>>
>>> but now how can I use it in my scripts who needs to use this
>>> connection ? for exemple I consider $dbh as the connection reference
>>
>>
>>
>> I've never used connect_on_init() but usually Apache::DBI is
>> completely transparent. You simply call DBI->connect and Apache::DBI
>> will intercept the request and return a persistant connection if there
>> is on with matching connection information.
>>
>
> Thanks :)
But now I'm asking about how to solve this :
I got in my environement multiple web sites and databaes. How can I deal
with this ?
thx in advance
------------------------------
Date: Fri, 04 Mar 2005 15:09:49 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: persistant db connection
Message-Id: <d09tds$aas$1@sun3.bham.ac.uk>
Alexandre Jaquet wrote:
[ excessive quotage - please include just enough to give context ]
> But now I'm asking about how to solve this :
>
> I got in my environement multiple web sites and databaes. How can I deal
> with this ?
Can you explain why you perceive there to be a problem?
Apache::DBI will maintain one persistant connection for each database
for each Perl interpreter.
------------------------------
Date: Fri, 4 Mar 2005 15:03:22 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Problem with debugging utf8 data - was Re: How to NOT use utf8.
Message-Id: <Pine.LNX.4.61.0503041410500.21265@ppepc56.ph.gla.ac.uk>
On Fri, 25 Feb 2005, Alan J. Flavell wrote:
> Sorry, I can't reproduce this behaviour in ActivePerl 5.8.1
> on Win2K.
Oh dear. I finally got there: I *can* reproduce the problem
in Perl 5.8.6, and that goes for ActivePerl, and for Cygwin Perl,
and for a version of Perl 5.8.6 built from source on (what is in
effect) RHEL 3.03 linux.
And the recipe for reproducing a problem can be as simple as this:
___
/
#!/usr/bin/perl -d
use strict;
use warnings;
use Carp qw( cluck );
my $msg = "value1\x{100}";
cluck $msg;
\___
and "c"ontinue from the debugger prompt.
One gets similar consequences (as the O.P already pointed out in a
different context) even if your string contains only ASCII characters,
so long as it has the utf8 flag set (for example, if you took an ASCII
substring from the above utf8 string, leaving the utf8 property set).
Well, the detailed consequences of executing the above code seem to be
different from implementation to implementation. On the Windows
platform, it can produce an alert from Windows saying that the program
has crashed. In other situations I've seen it reporting "Malformed
UTF-8 character". I've even seen it go into an endless loop with 99%
cpu utilisation - and unable to terminate it with ctrl/C.
However, I built 5.9.1 (i.e development version) and tried it on that,
and it seemed to work OK. So it looks as if the bug has been fixed in
the development version. I don't know off-hand which versions are
affected by the problem, though. I didn't get a problem in 5.8.1.
h t h
------------------------------
Date: 04 Mar 2005 13:02:35 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: ranking texts against a white list
Message-Id: <yzdhdjrwrdw.fsf@invalid.net>
"Mario Protto" <mario AT mario-online DOT com@usaquelloprimadichiocciola.invalid> writes:
>
> I have many small texts (200-1000 chars), I have a white list (100 words), I
> have to evaluate any text with its relevancy against the word list.
> Now I'm using a very simple alg like
> _______________________
> in text there is at least 1 word from list?
> yes --> rank = 1
> no --> rank = 0
> _______________________
>
> but I'd like rank to be a real number between 0 and 1, I have think
> something like count how many differnt word there are in test and normalize
> to 1 but perhaps there is some other, most intelligent...;), way to do that
> ....any suggest?
This question doesn't have anything to do with Perl, until there is
a particular implementation problem you want help with, so this is
not the proper news group for it.
If you don't know what the meaning of the relevancy number is, how
can anyone else? It's easy to start speculating, but before even doing
that I would want to know how the number is to be used.
If you search with google using some of the words "rank text white list",
you may find more information. Another source of ideas is documentation
(and source) of existing text search and ranking tools. 'Glimpse' comes
to mind, but there are probably many.
There's probably a proper news group dealing with such questions, but
I don't know what it might be called.
------------------------------
Date: Fri, 4 Mar 2005 14:00:40 +0100
From: "Mario Protto" <mario AT mario-online DOT com@usaquelloprimadichiocciola.invalid>
Subject: Re: ranking texts against a white list
Message-Id: <d09m58$e3c$1@area.cu.mi.it>
>> I have many small texts (200-1000 chars), I have a white list (100
>> words), I
>> have to evaluate any text with its relevancy against the word list.
>> Now I'm using a very simple alg like
>> _______________________
>> in text there is at least 1 word from list?
>> yes --> rank = 1
>> no --> rank = 0
>> _______________________
>>
>> but I'd like rank to be a real number between 0 and 1, I have think
>> something like count how many differnt word there are in test and
>> normalize
>> to 1 but perhaps there is some other, most intelligent...;), way to do
>> that
>> ....any suggest?
>
> This question doesn't have anything to do with Perl, until there is
> a particular implementation problem you want help with, so this is
> not the proper news group for it.
Ehm...sorry but I forgot to tell that this function is embedded in a Perl
project that start fetching text in a various way, putting it in a
Postgresql db and, via a PHP front-end, permit to human operators to filter
and show the contents.
> If you don't know what the meaning of the relevancy number is, how
> can anyone else? It's easy to start speculating, but before even doing
> that I would want to know how the number is to be used.
Well, the relevancy number could be something like "how much this document
talk about my terms", I know it could be almost a theoric question but it
seems to me as a common needed for perl programmer managing text...isn't it?
> If you search with google using some of the words "rank text white list",
> you may find more information. Another source of ideas is documentation
> (and source) of existing text search and ranking tools. 'Glimpse' comes
> to mind, but there are probably many.
of course I've done some Cpan and Google search before my post, also (for
who is interested) in italian newsgroup about Perl Stefano Rodighiero
suggest a very interesting article:
* "Building a Vector Space Search Engine in Perl"
http://www.perl.com/pub/a/2003/02/19/engine.html
> There's probably a proper news group dealing with such questions, but
> I don't know what it might be called.
me too...:)
Mario
------------------------------
Date: Fri, 04 Mar 2005 14:02:42 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: ranking texts against a white list
Message-Id: <42285c7a$1@news.kcl.ac.uk>
Mario Protto wrote:
> hi all,
>
> I have many small texts (200-1000 chars), I have a white list (100 words), I
> have to evaluate any text with its relevancy against the word list.
> Now I'm using a very simple alg like
> _______________________
> in text there is at least 1 word from list?
> yes --> rank = 1
> no --> rank = 0
> _______________________
>
> but I'd like rank to be a real number between 0 and 1, I have think
> something like count how many differnt word there are in test and normalize
> to 1 but perhaps there is some other, most intelligent...;), way to do that
> ....any suggest?
>
Hi
check out
http://www.perl.com/pub/a/2003/02/19/engine.html
is an article on building vector-space searches. May be what you are after.
Mark
------------------------------
Date: 4 Mar 2005 14:17:58 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: ranking texts against a white list
Message-Id: <Xns960F5E9995EABasu1cornelledu@132.236.56.8>
"Mario Protto" <mario AT mario-online DOT
com@usaquelloprimadichiocciola.invalid> wrote in
news:d09m58$e3c$1@area.cu.mi.it:
>>> I have many small texts (200-1000 chars), I have a white list (100
>>> words), I have to evaluate any text with its relevancy
...
>>> but I'd like rank to be a real number between 0 and 1, I have think
>>> something like count how many differnt word there are in test and
...
>> This question doesn't have anything to do with Perl, until there is
>> a particular implementation problem you want help with, so this is
>> not the proper news group for it.
>
> Ehm...sorry but I forgot to tell that this function is embedded in a
> Perl project that start fetching text in a various way,
Still irrelevant.
To get a better idea of what types of topics are relevant here, you should
read the posting guidelines for this group. They are posted here regularly
or you can Google for them on the web.
Sinan
------------------------------
Date: Fri, 04 Mar 2005 15:35:38 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Re: ranking texts against a white list
Message-Id: <Xns960F6BC44DEEFdkwwashere@216.168.3.30>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> "Mario Protto" <mario AT mario-online DOT
> com@usaquelloprimadichiocciola.invalid> wrote in
> news:d09m58$e3c$1@area.cu.mi.it:
>
>>>> I have many small texts (200-1000 chars), I have a white list
>>>> (100 words), I have to evaluate any text with its relevancy
> ...
>
>>>> but I'd like rank to be a real number between 0 and 1, I have
>>>> think something like count how many differnt word there are in
>>>> test and
> ...
>
>>> This question doesn't have anything to do with Perl, until there
>>> is a particular implementation problem you want help with, so
>>> this is not the proper news group for it.
>>
>> Ehm...sorry but I forgot to tell that this function is embedded
>> in a Perl project that start fetching text in a various way,
>
> Still irrelevant.
Maybe comp.programming? It seems like it might be a better place to
discuss an algorithm without caring about what language it's
implemented in.
> To get a better idea of what types of topics are relevant here,
> you should read the posting guidelines for this group. They are
> posted here regularly or you can Google for them on the web.
I bet Google hates the use of their trademarked name as a generic
verb.... :-)
--
David Wall
------------------------------
Date: Fri, 04 Mar 2005 13:55:03 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Setting environment with a script
Message-Id: <d09p1l$87n$1@sun3.bham.ac.uk>
A. Farber wrote:
> I have a question not related to Perl's syntax, but to its usage.
You've almost partitioned the problem but you've just stopped one step
short. You problem is about the ways processes can interact under
windows - the fact that one or more of the script is in Perl is not
relevant.
> With Unix that's easy - I'll let the users call my script as
>
> eval `create_makefiles.pl` in sh
> and
> eval `create_makefiles.pl -c` in csh
>
> and generate export/setenv commands when called this way.
>
> But what could I do to make it also work on Windows?
You can have the Perl script create a batch file the call that batch
file. There may be better ways but this is really a question about
Windows not Perl so perhaps you should ask in a Windows newsgroup.
------------------------------
Date: Fri, 04 Mar 2005 13:20:15 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: Subroutine Function
Message-Id: <jgZVd.59035$W16.23340@trndny07>
Brian McCauley wrote:
>
> Jim Keenan wrote:
>
>> nicolas-laurent wrote:
>>
>>> my $sub;
>>
>>
>> A very poor choice of variable name, because 'sub' is a keyword in
>> Perl ... as shown above.
>
>
> Since Perl variables hav sigils there's no problem with having the same
> name for a Perl variable and a function or keyword.
>
No problem for the compiler. It's only a problem for the humans.
Higher probability of being misread. Higher probability of typing
errors. Not a good practice, particularly for a beginner (which is
where I think the OP is at).
jimk
------------------------------
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 V10 Issue 7856
***************************************