Database Connections Global Variables

2003-07-25 Thread Levon Barker
Hello, I have a question. If I have a $dbh global variable in a particular module that I 'use'. I know that Apache::DBI will give a cached connection to the module to use. But what if I do something like $dbh-commit(); Is it possible that I am committing data for another session by accident?

Re: Database Connections Global Variables

2003-07-25 Thread Perrin Harkins
On Fri, 2003-07-25 at 14:55, Levon Barker wrote: If I have a $dbh global variable in a particular module that I 'use'. I know that Apache::DBI will give a cached connection to the module to use. There is no need to use a global. Apache::DBI caches it for you. If you put it in a global, then

Re: Are global variables truly global?

2001-11-05 Thread Dominique Quatravaux
I have some state data that I need to persist between requests. At the moment these are COM objects, but they'll be ported to Perl Classes. It is quite important that only one of these instances exist per web server. These instances are too large to write and read to file on every request.

RE: Are global variables truly global?

2001-11-05 Thread Matt Sergeant
-Original Message- From: Chui G. Tey [mailto:[EMAIL PROTECTED]] package Apache::MyPkg; my $COM_instance; sub handler { if (!$COM_instance) { $COM_instance = Win32::OLE-new(ProgID.Class); } } Will the different child processes created by Apache share the

Are global variables truly global?

2001-11-04 Thread Chui G. Tey
I have some state data that I need to persist between requests. At the moment these are COM objects, but they'll be ported to Perl Classes. It is quite important that only one of these instances exist per web server. These instances are too large to write and read to file on every request. So I

Re: Are global variables truly global?

2001-11-04 Thread Steven Lembark
and read to file on every request. So I have defined the variable as a package level variable. I have been instantiating the variable in my handler() routine if it has not already been instantiated. ie. Global variables are exactly that: global. If you use something like: our $foo

Re: Are global variables truly global?

2001-11-04 Thread Perrin Harkins
Will the different child processes created by Apache share the same variable? Or will each child create an additional instance? Each child has a separate interpreter and thus a separate instance of your global. If you need to co-ordinate data between processes, you might want to look at

Re: Global variables

2001-05-16 Thread will trillich
, this is a question which may be not right here ! I don`t want to use the perlmodule CGI !! I hope some persons can help me, primarily, global variables are looked down upon. but like the error message says, you can explicitly name any global like this: $The::Meaning::Of::Life::The::Universe

Global variables

2001-05-15 Thread Bjoern
Hi all, i want to define a global variable which is also present in subroutines coded in extra perl modules. I tried this our $test; but amod_perl tells me following Global symbol $test requires explicit package name I know, this is a question which may be not right here ! I don`t want to use

Global Variables Question

2001-04-25 Thread Warren D. Johnson
test.pl On the first run of the script G_ROOTPATH in test.pl has the value of home/warren... subsequent runs, it does not. I'm a little confused as to exact ways modperl handles global variables. Anyone have a simple tweak for this? Or do I have to make a config package? Thanks in advance!

Re: Global Variables Question

2001-04-25 Thread Mike Cameron
modperl handles global variables. Anyone have a simple tweak for this? Or do I have to make a config package? Thanks in advance!

Re: mod_perl forgets filled global variables

2001-04-01 Thread G.W. Haywood
Hi Werner, On Fri, 30 Mar 2001, werner.schmidt-wilczek wrote: I am using mod_perl for our Intranet. The performance is great, but there are many sideeffects! http://perl.apache.org/guide :) sometimes it seems mod_perl has forgotten the array. There are many ways of sharing data between

mod_perl forgets filled global variables

2001-03-30 Thread werner.schmidt-wilczek
Hi, my name is Werner Schmidt-Wilczek, i am a programmer at the Policegovernment in Nuremberg, Bavaria, Germany. I am using mod_perl for our Intranet. The performance is great, but there are many sideeffects! An example: I have a database with 5 items. I load this items one time

Re: sorting subroutine and global variables

2000-12-21 Thread Alexander Farber (EED)
Hi, thanks for your reply, Stas Bekman wrote: On Wed, 20 Dec 2000, Alexander Farber (EED) wrote: sub mysort { my $param = $query - param ('sort') || 'MHO'; # XXX global $query, # not mod_perl clean? return $a - {$param} cmp

Re: sorting subroutine and global variables

2000-12-21 Thread Stas Bekman
On Thu, 21 Dec 2000, Alexander Farber (EED) wrote: Stas Bekman wrote: On Wed, 20 Dec 2000, Alexander Farber (EED) wrote: sub mysort { my $param = $query - param ('sort') || 'MHO'; # XXX global $query, # not mod_perl clean?

sorting subroutine and global variables

2000-12-20 Thread Alexander Farber (EED)
Hi, http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S advises not to use external "my $variables" from subroutines. I have the following subroutine in my CGI-script, which I would like to keep mod_perl-kosher, just in case:

Re: sorting subroutine and global variables

2000-12-20 Thread Stas Bekman
n http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S PS: Is there something to be aware of, when using the new "our" keyword? our == use vars, which declares global variables. _ Stas Bekman JAm_

Re: global variables and reparsing (short reproducible example)

2000-11-25 Thread Stas Bekman
On 24 May 2000, Randal L. Schwartz wrote: "tayers" == [EMAIL PROTECTED] writes: tayers Given the above more complete descriptions I would say the usage in tayers Lperlsub is confusing. I agree with that, and with your general observation. From my hanging out on P5P, a subroutine is

Global variables II [and DBI]

2000-06-30 Thread Tomas Zeman
OK thanks, but how I create a global variable, which will be global for all apache processes together ? and I have nother problem what is a right usage of using DBI in script ? I have a Apache::DBI , DBI and connect_on_init in my startup.pl and connection is established OK. what should than i

global variables in mod_perl

2000-06-29 Thread Tomas Zeman
Hi all, I am new to mod_perl and i have one problembr I want to rewrite this simple script from fastcgi to mdo_perl - use FCGI; $cnt = 0; while (FCGI::Accept) { print "Content-type:text/html\n\n"; print $cnt++; } - This script writes (when i relaod it) 1,2,3,4,5,... and

Re: global variables in mod_perl

2000-06-29 Thread Richard Dice
I am new to mod_perl and i have one problembr . . . This script writes 1,1,1,2,2,2,3,3,3,2,2,3,4,2,1 . randomly !! Global variables are your problem. The thing is, each global has a value that is persistent... IN ANY GIVEN APACHE CHILD PROCESS! So, your increments are working, but you

Re: global variables in mod_perl

2000-06-29 Thread Casey Bristow
seems to me, that the script is working as it should.. you are just hitting several different instances of the script.. one for each apache child process.. try starting apache with the -X flag. './httpd -X' .. this will cause apache to run in single process mode. hope this helps. On

Re: global variables and reparsing (short reproducible example)

2000-06-01 Thread Doug MacEachern
On Fri, 26 May 2000, Marc Lehmann wrote: On Thu, May 25, 2000 at 12:09:09PM -0700, Doug MacEachern [EMAIL PROTECTED] wrote: You can only configure Apache from Perl sections, but you can load all your modules, shared data, etc. from a file pulled in with PerlRequire. actually you can,

Re: global variables and reparsing question (low priority ;)

2000-06-01 Thread Doug MacEachern
forget about mod_perl for a moment. yes, true, Perl's built-in require will not reload a module if it's already in %INC. but that's doesn't mean a Perl environment cannot un-cache that entry so it will be reloaded. consider the code below, pretend that loop is a long-lifetime server, Tk type

Re: global variables and reparsing question (low priority ;)

2000-06-01 Thread Doug MacEachern
On Fri, 26 May 2000, Marc Lehmann wrote: I know this and I have no problems with that (as I made very clear in my last mail). But when mod_perl requires special programming techniques this does not mean that code not using that techniques is "broken anyway", as dougm said, at least not in

Re: global variables and reparsing question (low priority ;)

2000-06-01 Thread Marc Lehmann
On Thu, Jun 01, 2000 at 11:59:53AM -0700, Doug MacEachern [EMAIL PROTECTED] wrote: will not reload a module if it's already in %INC. but that's doesn't mean a Perl environment cannot un-cache that entry so it will be reloaded. consider the code below, pretend that loop is a long-lifetime

Re: global variables and reparsing question (low priority ;)

2000-06-01 Thread Perrin Harkins
On Thu, 1 Jun 2000, Marc Lehmann wrote: It's easy, I just have to kick my ass each time I want to use a lexical for data abstraction and use a package variable instead, with only the exception that I have to be very careful that I never re-use the same name. This is quite difficult for code

Re: global variables and reparsing question (low priority ;)

2000-05-26 Thread Marc Lehmann
On Fri, May 26, 2000 at 10:33:15AM -0400, Geoffrey Young [EMAIL PROTECTED] wrote: mod_perl sometimes requires special perl coding guidelines, due in part to the way mod_perl works with and within apache. I know this and I have no problems with that (as I made very clear in my last mail). But

Re: global variables and reparsing question (low priority ;)

2000-05-26 Thread Daniel Jacobowitz
On Tue, May 23, 2000 at 10:05:01AM +0200, Marc Lehmann wrote: On Tue, May 23, 2000 at 12:56:28AM -0500, Autarch [EMAIL PROTECTED] wrote: On Tue, 23 May 2000, Marc Lehmann wrote: stable (mod_perl really is very unstable for large applications). Apart Wow, I wish you'd warned me

Re: global variables and reparsing question (low priority ;)

2000-05-25 Thread Doug MacEachern
On Wed, 24 May 2000, Marc Lehmann wrote: You must be kidding here!!! Using lexicals on package level is broken??? If it is broken, then _why_ is it recommended programming practise in perl (see perltoot for example)? i'm not kidding. i don't understand whay you mean by 'using lexicals on

Re: global variables and reparsing (short reproducible example)

2000-05-25 Thread Doug MacEachern
On Wed, 24 May 2000, Perrin Harkins wrote: On Wed, 24 May 2000, Marc Lehmann wrote: I was under the impression that you cannot configure Apache from a PerlRequire. If that is not the case (and somehow works) I'd really like to get away from perlsections. You can only configure Apache

Re: global variables and reparsing (short reproducible example)

2000-05-25 Thread Marc Lehmann
On Thu, May 25, 2000 at 12:09:09PM -0700, Doug MacEachern [EMAIL PROTECTED] wrote: You can only configure Apache from Perl sections, but you can load all your modules, shared data, etc. from a file pulled in with PerlRequire. actually you can, if a module defines variables in the

Re: global variables and reparsing question (low priority ;)

2000-05-25 Thread Marc Lehmann
On Thu, May 25, 2000 at 11:58:38AM -0700, Doug MacEachern [EMAIL PROTECTED] wrote: You must be kidding here!!! Using lexicals on package level is broken??? If it is broken, then _why_ is it recommended programming practise in perl (see perltoot for example)? i'm not kidding. i don't

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Marc Lehmann
On Tue, May 23, 2000 at 04:07:40PM -0700, Perrin Harkins [EMAIL PROTECTED] wrote: This is a combination of closures and PerlFreshRestart biting (still no closures) My example might be misleading, since I used x before it was defined (to make the example short). Typical examples look like this:

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Marc Lehmann
On Wed, May 24, 2000 at 12:52:37AM +0300, Stas Bekman [EMAIL PROTECTED] wrote: You can control what's being reloaded and what's not: http://perl.apache.org/guide/config.html#Apache_Restarts_Twice_On_Start

Re: global variables and reparsing question (low priority ;)

2000-05-24 Thread Marc Lehmann
Huh? Why is "do" a bad thing Do is bad because it is called every time, even if you've already executed You are confused about the two different forms of do. The do BLOCK form I used has nothing to do with the do EXPR form you seem to be confused about. perldoc -f do explains the

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Marc Lehmann
On Tue, 23 May 2000, Perrin Harkins wrote: Your sub x is a closure. That's why it returns the previous value of No. In perl, a closure is *defined* as "anonymous subroutine" (see the documentation). If you define it different, you are right, but you are not talking about perl then. --

Re: global variables and reparsing question (low priority ;)

2000-05-24 Thread Marc Lehmann
On Tue, May 23, 2000 at 08:22:59PM -0700, Doug MacEachern [EMAIL PROTECTED] wrote: If this were true, it would be very bad. If there is no technical need to do this "half-reloading" then it should definitely be turned off. it is off by default, you turned it on with 'PerlFreshRestart On'

Re: global variables and reparsing question (low priority ;)

2000-05-24 Thread Ken Williams
[EMAIL PROTECTED] (Marc Lehmann) wrote: flag to keep from compiling again and checking $@ yourself, so you're getting around these problems, but the file form of do is generally a red flag. This is just as saying "division is a bad thing in general, because it let's you try to divide by

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Randal L. Schwartz
"tayers" == [EMAIL PROTECTED] writes: tayers Given the above more complete descriptions I would say the usage in tayers Lperlsub is confusing. I agree with that, and with your general observation. From my hanging out on P5P, a subroutine is only a closure when it sees lexical variables and

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Perrin Harkins
On Wed, 24 May 2000, Marc Lehmann wrote: On Wed, May 24, 2000 at 12:52:37AM +0300, Stas Bekman [EMAIL PROTECTED] wrote: You can control what's being reloaded and what's not: http://perl.apache.org/guide/config.html#Apache_Restarts_Twice_On_Start

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Perrin Harkins
On Wed, 24 May 2000, Marc Lehmann wrote: I was under the impression that you cannot configure Apache from a PerlRequire. If that is not the case (and somehow works) I'd really like to get away from perlsections. You can only configure Apache from Perl sections, but you can load all your

Re: global variables and reparsing (short reproducible example)

2000-05-24 Thread Marc Lehmann
On Wed, May 24, 2000 at 11:30:40AM -0700, Perrin Harkins [EMAIL PROTECTED] wrote: example did something similar, indeed, but it had to be embedded into the module source, which is somewhat inconvinient. If you don't have PerlFreshRestart turned on (it is not recommended on production

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Perrin Harkins
I don't quite understand what you're trying to do, but what you have here is a closure and it looks like you want a real global instead. (man perlref if "closure" doesn't ring a bell.) Some of your language makes it look like you may have some confusion between global and lexicals. At any

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Marc Lehmann
On Tue, May 23, 2000 at 12:56:28AM -0500, Autarch [EMAIL PROTECTED] wrote: On Tue, 23 May 2000, Marc Lehmann wrote: stable (mod_perl really is very unstable for large applications). Apart Wow, I wish you'd warned me before I did several large applications using mod_perl. Fortunately,

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Marc Lehmann
On Tue, May 23, 2000 at 12:27:58PM +0800, Gunther Birznieks [EMAIL PROTECTED] wrote: replace my $global with use vars qw($global); and your problem should disappear. If you had read my mail you would have known that I do not search for a workaround. While in this simple example it is

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Matt Sergeant
On Tue, 23 May 2000, Marc Lehmann wrote: On Tue, May 23, 2000 at 12:56:28AM -0500, Autarch [EMAIL PROTECTED] wrote: On Tue, 23 May 2000, Marc Lehmann wrote: stable (mod_perl really is very unstable for large applications). Apart Wow, I wish you'd warned me before I did several

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Marc Lehmann
On Mon, May 22, 2000 at 11:24:10PM -0700, Perrin Harkins [EMAIL PROTECTED] wrote: business about being parsed twice only applies to Apache's config file and Perl sections in it, not to your modules. A little followup: Looking at the mod_perl source, I see that INC is tinkered with in a lot of

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Marc Lehmann
On Tue, May 23, 2000 at 09:26:13AM +0100, Matt Sergeant [EMAIL PROTECTED] wrote: Hmm... AxKit does all this, and is very stable for me, and I've only had a couple of reports of segfaults, none of which went unsolved as far as I know... OK. To be fair, I am not 100% sure wether it's an

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Ken Williams
[EMAIL PROTECTED] (Marc Lehmann) wrote: = package othermodule; my $global = 5; sub set_global { $global = shift; } = And use this from

global variables and reparsing (short reproducible example)

2000-05-23 Thread Marc Lehmann
On Tue, May 23, 2000 at 07:15:46AM -0500, Ken Williams [EMAIL PROTECTED] wrote: my $global = 5; sub set_global { $global = shift; } othermodule::set_global 7; = Then, to my surprise, _sometimes_ the $global

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Gustavo Duarte
helu. Marc Lehmann wrote: And so my question is: why does this behaviour exist, and why is it necessary (the documents I saw so far only told me that this "has something to do with apache's configuration file parsing", which doesn't explain much, especially as it does seem unnecessary).

Re: global variables and reparsing (short reproducible example)

2000-05-23 Thread Doug MacEachern
On Tue, 23 May 2000, Marc Lehmann wrote: As a related note, I wondered why there isn't a mod_perl callback that is clled _before_ forking, but after configuration parsing. This would allow a lot of data sharing between the httpd servers. My module requires you to call "configured PApp" at

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Marc Lehmann
On Tue, May 23, 2000 at 10:08:46AM -0700, Gustavo Duarte [EMAIL PROTECTED] wrote: I'm not sure this makes sense for your case, but it might help, so... It probably makes a lot of sense. Thanks! "When the server [apache] is restarted, the configuration and module initialization phases are

Re: global variables and reparsing (short reproducible example)

2000-05-23 Thread Marc Lehmann
On Tue, May 23, 2000 at 11:53:04AM -0700, Doug MacEachern [EMAIL PROTECTED] wrote: a lot of data sharing between the httpd servers. My module requires you to call "configured PApp" at the end of the configuration section so that it can pull in most of the code and big data structures before

Re: global variables and reparsing question (low priority ;)

2000-05-23 Thread Doug MacEachern
On Tue, 23 May 2000, Marc Lehmann wrote: At leats in the example I sent in there is no sign of any closure. There is a closure, and this might be the thing that's making trouble for you, or at least part of it. This is a closure: that example is only a closure if it's compiled by

Re: global variables and reparsing (short reproducible example)

2000-05-23 Thread Doug MacEachern
On Tue, 23 May 2000, Perrin Harkins wrote: Your sub x is a closure. That's why it returns the previous value of $x. When it gets re-defined, it should start looking at the value of the new $x. nevermind what i said in the other reply about not being a closure. you're right, it is by

global variables and reparsing question (low priority ;)

2000-05-22 Thread Marc Lehmann
While I understand how my problem happens, it just caught me again (letting me debug another two hours), and so I wanted to ask why this peculiar behaviour is really necessary. But straight to the point. If I have a module like this:

Re: global variables and reparsing question (low priority ;)

2000-05-22 Thread Gunther Birznieks
replace my $global with use vars qw($global); and your problem should disappear. At 05:40 AM 5/23/00 +0200, Marc Lehmann wrote: While I understand how my problem happens, it just caught me again (letting me debug another two hours), and so I wanted to ask why this peculiar behaviour is really

Re: global variables and reparsing question (low priority ;)

2000-05-22 Thread Autarch
On Tue, 23 May 2000, Marc Lehmann wrote: stable (mod_perl really is very unstable for large applications). Apart Wow, I wish you'd warned me before I did several large applications using mod_perl. Fortunately, they haven't experienced any mod_perl related problems. Just a fluke, I guess.