[25708] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7948 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 6 18:05:36 2005

Date: Wed, 6 Apr 2005 15:05:14 -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           Wed, 6 Apr 2005     Volume: 10 Number: 7948

Today's topics:
        [BEGINNER] Embperl question soup_or_power@yahoo.com
    Re: [BEGINNER] Embperl question <nobull@mail.com>
        Basic Regular Expressions question... <kd3qc@yahoo.com>
    Re: Basic Regular Expressions question... <1usa@llenroc.ude.invalid>
    Re: Basic Regular Expressions question... <kd3qc@yahoo.com>
    Re: Basic Regular Expressions question... <noreply@gunnar.cc>
    Re: Bug in timelocal? <mothra@nowhereatall.com>
    Re: Bug in timelocal? <yocoyote@gmail.com>
    Re: Bug in timelocal? <nobull@mail.com>
    Re: Bug in timelocal? <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Bug in timelocal? <mothra@nowhereatall.com>
    Re: Bug in timelocal? (Gary E. Ansok)
    Re: Bug in timelocal? (Gary E. Ansok)
    Re: Bug in timelocal? <yocoyote@gmail.com>
    Re: Bug in timelocal? <yocoyote@gmail.com>
    Re: Bug in timelocal? <comdog@panix.com>
    Re: Bug in timelocal? (Gary E. Ansok)
    Re: Bug in timelocal? (Gary E. Ansok)
        dbi statement handlers as package globals in mod_perl s <astrader@ecnext.com>
    Re: dbi statement handlers as package globals in mod_pe <nobull@mail.com>
    Re: Embperl question soup_or_power@yahoo.com
        output-monitoring module <henry.townsend@not.here>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 6 Apr 2005 12:00:36 -0700
From: soup_or_power@yahoo.com
Subject: [BEGINNER] Embperl question
Message-Id: <1112814036.807195.301800@g14g2000cwa.googlegroups.com>

Can someone please explain this sub taken out of embperl code. I am not
sure what the Storable::thaw is doing.Many thanks!
sub get_session {
  my ( $r ) = @_;

  if ( ref $r eq 'Apache' ) {

    # ------------------------------------------------
    #   session from Apache request
    # ------------------------------------------------

    my $cookie_head    = $r->header_in('Cookie');
    my $cookie_name    = $ENV{EMBPERL_COOKIE_NAME} || 'EMBPERL_UID';
    my ( $session_id ) = ($cookie_head =~
/$cookie_name=(.*?)(?:\;|\s|$)/);
    my %args = &get_session_env();

    my $dbh = DBI->connect(
      $args{DataSource},
      $args{UserName},
      $args{Password},
      { RaiseError => 0, AutoCommit => 1 }
    ) || return undef;

    my $session = $dbh->selectall_arrayref( q{
      SELECT a_session
      FROM sessions
      WHERE id = ?
    }, { }, $session_id );

    $dbh->disconnect();

    return ( defined $session && $session ) ? Storable::thaw(
$session->[0][0] ) : undef;
  } else {

    # ------------------------------------------------
    #   session from udat
    # ------------------------------------------------

    &session_synch( $r );

    return %$r;
  }
}



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

Date: Wed, 06 Apr 2005 20:15:16 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: [BEGINNER] Embperl question
Message-Id: <d31c55$l9t$1@sun3.bham.ac.uk>

soup_or_power@yahoo.com wrote:

> Can someone please explain this sub taken out of embperl code. I am not
> sure what the Storable::thaw is doing.

Rather than showing us the code where Storable::thaw is called it would 
perhaps be more productive if you showed us the part of the Storable 
documentation that you are finding hard to follow.



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

Date: 6 Apr 2005 09:17:01 -0700
From: "Will" <kd3qc@yahoo.com>
Subject: Basic Regular Expressions question...
Message-Id: <1112804221.588102.16580@o13g2000cwo.googlegroups.com>

Hi,
I have a longer program that finds and recursively replaces text in
many html files that works beautifully for most cases, but I think I'm
getting hung up on a s///  and regular expressions glitch.  I wrote a
very short program that gets to the heart of the matter...

################################################################################
use strict;
use warnings;


my
$find="https://sinaicentral.mssm.edu/intranet/intranet/ct_public/view?trial_id=MSM03204&searchNow=no";
my $replace="http://www.excite.com";


my $thisPage=
"https://sinaicentral.mssm.edu/intranet/intranet/ct_public/view?trial_id=MSM03204&searchNow=no";

$thisPage =~ s#$find#$replace#g;

print $thisPage;
################################################################################

To my understanding, this program should take the long string in $find
and then replace it with $replace and the output should be
"http://www.excite.com".  I think the "?" in the $find variable is
being treated as a Regular Expression but I can't figure out a way to
nullify that effect.  I'm a librarian not a programmer!  Sombody please
help! I'm working for a worthy non-profit that is strapped for cash, so
I have to figure this out! It will bring you good karma!  Thanks a
bunch!

Will Jiang



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

Date: Wed, 06 Apr 2005 16:29:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Basic Regular Expressions question...
Message-Id: <Xns96307F21241CAasu1cornelledu@127.0.0.1>

"Will" <kd3qc@yahoo.com> wrote in
news:1112804221.588102.16580@o13g2000cwo.googlegroups.com: 

> To my understanding, this program should take the long string in $find
> and then replace it with $replace and the output should be
> "http://www.excite.com".  I think the "?" in the $find variable is
> being treated as a Regular Expression but I can't figure out a way to
> nullify that effect.  

To put it correctly, ? is special in a regular expression.

perldoc perlreref

 ?       Matches the preceding element 0 or 1 times

also from the same document

 \Q  Disable pattern metacharacters until \E

$thispage =~ s{\Q$find\E}{$replace};

should work.

> I'm a librarian not a programmer!  Sombody
> please help! I'm working for a worthy non-profit that is strapped for
> cash, so I have to figure this out! It will bring you good karma! 

None of this increases your chances of getting help. Describing your 
problem accurately, as you did, is the crucial part.

For further information on how to help others help you, please see the 
posting guidelines for this group if you haven't already done so.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 6 Apr 2005 09:37:05 -0700
From: "Will" <kd3qc@yahoo.com>
Subject: Re: Basic Regular Expressions question...
Message-Id: <1112805425.248127.242080@f14g2000cwb.googlegroups.com>

THANKS SO MUCH!  I really appreciate the help!  Have a wonderful day!

Will Jiang
A. Sinan Unur wrote:
> "Will" <kd3qc@yahoo.com> wrote in
> news:1112804221.588102.16580@o13g2000cwo.googlegroups.com:
>
> > To my understanding, this program should take the long string in
$find
> > and then replace it with $replace and the output should be
> > "http://www.excite.com".  I think the "?" in the $find variable is
> > being treated as a Regular Expression but I can't figure out a way
to
> > nullify that effect.
>
> To put it correctly, ? is special in a regular expression.
>
> perldoc perlreref
>
>  ?       Matches the preceding element 0 or 1 times
>
> also from the same document
>
>  \Q  Disable pattern metacharacters until \E
>
> $thispage =~ s{\Q$find\E}{$replace};
>
> should work.
>
> > I'm a librarian not a programmer!  Sombody
> > please help! I'm working for a worthy non-profit that is strapped
for
> > cash, so I have to figure this out! It will bring you good karma!
>
> None of this increases your chances of getting help. Describing your
> problem accurately, as you did, is the crucial part.
>
> For further information on how to help others help you, please see
the
> posting guidelines for this group if you haven't already done so.
>
> Sinan
>
> --
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (reverse each component and remove .invalid for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: Wed, 06 Apr 2005 19:05:01 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Basic Regular Expressions question...
Message-Id: <3bijdjF6gg9jlU1@individual.net>

A. Sinan Unur wrote:
> 
>  \Q  Disable pattern metacharacters until \E
> 
> $thispage =~ s{\Q$find\E}{$replace};

Since escaping all the characters in PATTERN makes it a non-regex 
problem, I played with using index() and substr() instead:

     substr $thisPage, index($thisPage, $find), length $find, $replace;

However, to take the /g modifier into consideration (which the OP 
originally used), you seem to need something like:

     my ($i, $length) = (0,0);
     while ( ( $i = index $thisPage, $find, $i+$length ) >= 0 ) {
         $length = length $find;
         substr $thisPage, $i, $length, $replace;
     }

That's much typing to 'emulate'

     $thispage =~ s/\Q$find/$replace/g;

Assuming that using index() and substr() is more efficient than the 
using the s/// operator, is there any easier way to combine them to 
achieve the same result?

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


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

Date: Wed, 6 Apr 2005 08:11:21 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Bug in timelocal?
Message-Id: <4253fb17$1@usenet.ugs.com>


"yocoyote" <yocoyote@gmail.com> wrote in message
news:1112799270.458682.191040@o13g2000cwo.googlegroups.com...
(snipped)
> using activestate perl 5.8.4 build 810 on my pc.  I've found one date,

Which one? what was the date?

> among the 10,000's I've successfully transformed, is offset by 3600
> sec.  The 3600 (=1 hour) struck me as not likely a conincidence.  I'm
> wondering if others have seen this before.
Mothra




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

Date: 6 Apr 2005 09:02:12 -0700
From: "yocoyote" <yocoyote@gmail.com>
Subject: Re: Bug in timelocal?
Message-Id: <1112803332.554723.116710@z14g2000cwz.googlegroups.com>

Here are the dates:   the diff is negative, which highlighted the issue
$MonthSTART = 04, $DaySTART = 02, $HourSTART = 02, $MinSTART = 47,
$SecSTART = 07
(04/02 02:47:07)
$epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
$DaySTART, $MonthSTART-1);
I get $epochTimeSTART = 954672427
---
$MonthSTOP = 04, $DaySTOP = 02, $HourSTOP = 03, $MinSTOP = 09, $SecSTOP
= 08
(04/02 03:09:08)
$epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
$DaySTART, $MonthSTART-1);
I get $epochTimeSTOP = 954670148

So the calculated diff ($epochTimeSTOP - $epochTimeSTART) = -2279
The correct diff (I did by hand) = 1321

Note that 2279 + 1321 = 3600 !

So either the $epochTimeSTART was shifted up an hour or $epochTimeSTOP
was shifted back an hour.  These dates are close to daylight savings
time change in PST (where I'm at) but off by about 23 hrs.



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

Date: Wed, 06 Apr 2005 17:50:29 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Bug in timelocal?
Message-Id: <d313lm$h67$1@sun3.bham.ac.uk>



yocoyote wrote:

> I'm writing scripts which make heavy use of the timelocal() fct.
> (Time::Local) to get epochtime from a MM/DD hh:mm:ss text date.  I'm
> using activestate perl 5.8.4 build 810 on my pc.  I've found one date,
> among the 10,000's I've successfully transformed, is offset by 3600
> sec.  The 3600 (=1 hour) struck me as not likely a conincidence.  I'm
> wondering if others have seen this before.

Was this is the week following the DST transion perhaps?

I discovered last week that on some versions of the Win32 OS there's a 
but that sometimes causes it to report the wrong local time to some 
applications in the week following the DST transition.

(Note: I didn't come across this in Perl but in another language).

> Anyone seen instances in which a date, seemingly at random, has 3600
> added or subtracted from the correct output of timelocal?

I can't recall the details but I did many years ago note that 
Time::Local's algorithm was flawed.  I don't know if it was ever fixed.



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

Date: Wed, 6 Apr 2005 09:57:05 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Bug in timelocal?
Message-Id: <20hdi2x0v5.ln2@goaway.wombat.san-francisco.ca.us>

On 2005-04-06, yocoyote <yocoyote@gmail.com> wrote:
> $MonthSTART = 04, $DaySTART = 02, $HourSTART = 02, $MinSTART = 47,
> $SecSTART = 07
> (04/02 02:47:07)
> $epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
> $DaySTART, $MonthSTART-1);
> I get $epochTimeSTART = 954672427
> ---
> $MonthSTOP = 04, $DaySTOP = 02, $HourSTOP = 03, $MinSTOP = 09, $SecSTOP
>= 08
> (04/02 03:09:08)
> $epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
> $DaySTART, $MonthSTART-1);
> I get $epochTimeSTOP = 954670148
>
> So the calculated diff ($epochTimeSTOP - $epochTimeSTART) = -2279

Please post a complete, working Perl script.  The above makes people
edit your code by hand in order to even start to help you.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information



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

Date: Wed, 6 Apr 2005 10:10:09 -0700
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Bug in timelocal?
Message-Id: <425416ef$1@usenet.ugs.com>


"yocoyote" <yocoyote@gmail.com> wrote in message
news:1112803332.554723.116710@z14g2000cwz.googlegroups.com...
> So either the $epochTimeSTART was shifted up an hour or $epochTimeSTOP
> was shifted back an hour.  These dates are close to daylight savings
> time change in PST (where I'm at) but off by about 23 hrs.

I was unable to reproduce your problem.

 use strict;
use warnings;
use Time::Local;

my @start = qw(07 47 02 02 03);
my @end   = qw(08 09 03 02 03);

my $estart = timelocal(@start);
my $estop  = timelocal(@end);

print "start time is: $estart\n";
print "End time is: $estop\n";

my $diff = $estop - $estart;

print "the difference is: $diff\n";


output is
F:\scripts>me.pl
start time is: 954672427
End time is: 954673748
the difference is: 1321





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

Date: Wed, 6 Apr 2005 17:30:27 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Bug in timelocal?
Message-Id: <d316bj$em7$1@naig.caltech.edu>

In article <1112803332.554723.116710@z14g2000cwz.googlegroups.com>,
yocoyote <yocoyote@gmail.com> wrote:
>Here are the dates:   the diff is negative, which highlighted the issue
>$MonthSTART = 04, $DaySTART = 02, $HourSTART = 02, $MinSTART = 47,
>$SecSTART = 07
>(04/02 02:47:07)
>$epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
>$DaySTART, $MonthSTART-1);
>I get $epochTimeSTART = 954672427
>---
>$MonthSTOP = 04, $DaySTOP = 02, $HourSTOP = 03, $MinSTOP = 09, $SecSTOP
>= 08
>(04/02 03:09:08)
>$epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
>$DaySTART, $MonthSTART-1);
>I get $epochTimeSTOP = 954670148
>
>So the calculated diff ($epochTimeSTOP - $epochTimeSTART) = -2279
>The correct diff (I did by hand) = 1321
>
>Note that 2279 + 1321 = 3600 !
>
>So either the $epochTimeSTART was shifted up an hour or $epochTimeSTOP
>was shifted back an hour.  These dates are close to daylight savings
>time change in PST (where I'm at) but off by about 23 hrs.

This might help clear up your confusion:
print scalar localtime $epochTimeSTART;

Why do you not specify a year in your call to timelocal()?  Do you
know what timelocal() uses when you don't specify a year?

Yes, it is a DST time changeover issue.  No, it's not a bug.
"If the timelocal() function is given a non-existent local time, 
it will simply return an epoch value for the time one hour later."

Gary Ansok
-- 
It's depressing that the words "secret agent"
have become synonymous with "sex maniac."
        -- Sir James Bond, _Casino Royale_


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

Date: Wed, 6 Apr 2005 19:07:37 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Bug in timelocal?
Message-Id: <d31c1p$gr9$1@naig.caltech.edu>

In article <d316bj$em7$1@naig.caltech.edu>,
Gary E. Ansok <ansok@alumni.caltech.edu> wrote:
>In article <1112803332.554723.116710@z14g2000cwz.googlegroups.com>,
>yocoyote <yocoyote@gmail.com> wrote:
>>Here are the dates:   the diff is negative, which highlighted the issue
>>$MonthSTART = 04, $DaySTART = 02, $HourSTART = 02, $MinSTART = 47,
>>$SecSTART = 07
>>(04/02 02:47:07)
>>$epochTimeSTART = timelocal($SecSTART, $MinSTART, $HourSTART,
>>$DaySTART, $MonthSTART-1);
>>I get $epochTimeSTART = 954672427
>>So either the $epochTimeSTART was shifted up an hour or $epochTimeSTOP
>>was shifted back an hour.  These dates are close to daylight savings
>>time change in PST (where I'm at) but off by about 23 hrs.
>
>This might help clear up your confusion:
>print scalar localtime $epochTimeSTART;
>
>Why do you not specify a year in your call to timelocal()?  Do you
>know what timelocal() uses when you don't specify a year?

I might add that if you had had Perl's warnings turned on, you would
have gotten messages that might have led you to the correct answer
without needing outside help.

Gary
-- 
New Year's Resolution:  I will not sphroxify gullible people into looking up 
fictitious words in the dictionary.  (Chuck Robey)


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

Date: 6 Apr 2005 12:39:53 -0700
From: "yocoyote" <yocoyote@gmail.com>
Subject: Re: Bug in timelocal?
Message-Id: <1112816393.618716.18210@l41g2000cwc.googlegroups.com>

Thank you. Thank you.

By explicitly adding the year to the timelocal() call, I get the
correct value of 1321.

I am still trying to reconcile some of the comments above (clearly
accurate) with the details of how this occurred, i.e., early on a Sat
morning (not Sun) and the time ($epochStopTime was affected) seemed to
move back, rather than forward ("spring forward")

-yocoyote



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

Date: 6 Apr 2005 12:44:03 -0700
From: "yocoyote" <yocoyote@gmail.com>
Subject: Re: Bug in timelocal?
Message-Id: <1112816643.290785.244060@l41g2000cwc.googlegroups.com>

definitely good input and consistent with all the books i've read.
what i don't understand is which i didnt get the warnings because i had
"use warnings;" at the top of my code.
i get no warnings with or without the -c at the command prompt  ??

at any rate, thanks again



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

Date: Wed, 06 Apr 2005 15:08:56 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Bug in timelocal?
Message-Id: <060420051508569238%comdog@panix.com>

In article <1112803332.554723.116710@z14g2000cwz.googlegroups.com>,
yocoyote <yocoyote@gmail.com> wrote:

> Here are the dates:   the diff is negative, which highlighted the issue
> $MonthSTART = 04, $DaySTART = 02, $HourSTART = 02, $MinSTART = 47,
> $SecSTART = 07

You're missing an hour on the day that daylight savings starts?
That's odd.

-- 
brian d foy, comdog@panix.com
Subscribe to The Perl Review: http://www.theperlreview.com


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

Date: Wed, 6 Apr 2005 20:56:17 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Bug in timelocal?
Message-Id: <d31idh$je9$1@naig.caltech.edu>

In article <1112816393.618716.18210@l41g2000cwc.googlegroups.com>,
yocoyote <yocoyote@gmail.com> wrote:
>Thank you. Thank you.
>
>By explicitly adding the year to the timelocal() call, I get the
>correct value of 1321.
>
>I am still trying to reconcile some of the comments above (clearly
>accurate) with the details of how this occurred, i.e., early on a Sat
>morning (not Sun) and the time ($epochStopTime was affected) seemed to
>move back, rather than forward ("spring forward")

Did you try the line I suggested:

print scalar localtime $epochTimeSTART;

I get
Sun Apr  2 03:09:08 2000

If you don't supply a year to timelocal(), it gets undef as the
year value.  When that is used numerically, it becomes a 0.
If you read the docs for Time::Local, you'll find that 0 is
treated as 2000 (until 2050, when 0 will be treated as 2100).

While it might be useful in some cases for timelocal() to assume
the current year if none is supplied, it doesn't.  You could write
to the maintainer and suggest the behavior you want.

Gary
-- 
The recipe says "toss lightly," but I suppose that depends 
on how much you eat and how bad the cramps get.


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

Date: Wed, 6 Apr 2005 20:59:59 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Bug in timelocal?
Message-Id: <d31ikf$jfd$1@naig.caltech.edu>

In article <1112816643.290785.244060@l41g2000cwc.googlegroups.com>,
yocoyote <yocoyote@gmail.com> wrote:
>definitely good input and consistent with all the books i've read.
>what i don't understand is which i didnt get the warnings because i had
>"use warnings;" at the top of my code.
>i get no warnings with or without the -c at the command prompt  ??

Ah.  Since I was running this as a quick one-liner at the command prompt,
I used -w (which turns on warnings everywhere).  You used "use warnings",
which turns on warnings in the file or block where it appears.

These warnings are generated within Time::Local, which explains why I
saw them and you didn't.

Both have advantages and disadvantages, but "use warnings" is probably
the better way to go overall.

Gary
-- 
Quidquid latine dictum sit, altum viditur. 
Whatever is said in Latin sounds profound.


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

Date: 6 Apr 2005 11:26:37 -0700
From: "Andrew S" <astrader@ecnext.com>
Subject: dbi statement handlers as package globals in mod_perl script
Message-Id: <1112811997.602768.262010@l41g2000cwc.googlegroups.com>

I am working to enhance the performance of a few mod_perl scripts on
some clients' web sites. One of the optimizations that I have read
about is to store DBI statement handles as package globals, so that
they can be re-used within the same process. My concern is that
something bad may happen if/when a database connection is dropped. I
realize that Apache::DBI will handle dropped connections gracefully,
but all statement handles prepared from the original database handle
will become invalid, won't they?

Here is some code:

========
use Apache::DBI;
use strict;
use vars($dbh $sth);
 ...
$dbh ||= DBI->connect(...);
$sth ||= $dbh->prepare("select * from tbl where id = ?");
 ...
$sth->execute($id);
@result = $sth->fetchrow_array;
 ...
========

The idea here is to initialize a database handle and a statement handle
once when the script is first loaded by a process. Thereafter, any web
requests handled by the same process can re-use the statement handle.
To the best of my knowledge, this is the most optimal solution. If I
initialized the statement handle every time the code was run, then I
would incur the overhead of calling the prepare method every time. But
as I said, I am a little paranoid about what would happen to $sth if
the database connection associated with $dbh has to be re-established.

Has anyone ever used package-global statement handles successfully? If
so, can you tell me whether the above code is right. Otherwise, what
recommendations would you make?



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

Date: Wed, 06 Apr 2005 20:10:09 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: dbi statement handlers as package globals in mod_perl script
Message-Id: <d31brh$l5l$1@sun3.bham.ac.uk>



Andrew S wrote:

> I am working to enhance the performance of a few mod_perl scripts on
> some clients' web sites. One of the optimizations that I have read
> about is to store DBI statement handles as package globals, so that
> they can be re-used within the same process. My concern is that
> something bad may happen if/when a database connection is dropped. I
> realize that Apache::DBI will handle dropped connections gracefully,
> but all statement handles prepared from the original database handle
> will become invalid, won't they?

Just use prepare_cache() and let someone else worry about that.



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

Date: 6 Apr 2005 12:51:28 -0700
From: soup_or_power@yahoo.com
Subject: Re: Embperl question
Message-Id: <1112817088.922775.158560@l41g2000cwc.googlegroups.com>


Brian McCauley wrote:
> soup_or_power@yahoo.com wrote:
>
> > Can someone please explain this sub taken out of embperl code. I am
not
> > sure what the Storable::thaw is doing.
>
> Rather than showing us the code where Storable::thaw is called it
would
> perhaps be more productive if you showed us the part of the Storable
> documentation that you are finding hard to follow.

Sorry I didn't mean to be lazy. Let me break it down:
a)what is EMBPERL_SESSION_ARGS and where will one have to specify. Are
they configured into apache?
For example below:
sub get_session_env {
  my %args;
  foreach ( split( /\s+/, $ENV{EMBPERL_SESSION_ARGS} ) ) {
    /^(.*?)\s*=\s*(.*?)$/;
    $args{$1} = $2;
  }

  return %args;
}


b)what is $ENV{EMBPERL_COOKIE_NAME} and why can it be defaulted as
'EMBPERL_UID'

c)how exactly is $session_id extracted in the code?

d)how can one store the session in a database?

Bottom line is I couldn't find a book on embperl. If you can suggest a
book I'll be grateful. 
Thanks



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

Date: Wed, 06 Apr 2005 16:08:50 -0400
From: Henry Townsend <henry.townsend@not.here>
Subject: output-monitoring module
Message-Id: <BuGdnScX07FP3MnfRVn-qQ@comcast.com>

Please forgive me for asking here, I have done some searches and come up
empty but I still think the module I need may have been written and want 
to know for sure before I go trying to roll my own.

I'm thinking of writing a module which would monitor the output of any
script which "use"d it looking for errors. E.g. something like this

use Output::Monitor STDOUT => qr/re1/, STDERR => qr/re2/;

This would - perhaps by using tied filehandles - watch all data flowing
to stdout and stderr, apply the specified REs to each line, and convert
the exit status to nonzero if any matches occur. The data would still be 
delivered to the same place, just checked along the way.

The idea is to replace a common technique where I work, which is to
write build scripts which divert their own output to a log internally,
then read that logfile to discover any unflagged errors. This makes it
hard for external tools to redirect output as they choose, requires
intimate knowledge of the script to know where it's writing its logfile
to, etc. What I'd hope to achieve with the above is transparency, i.e.
by simply including the module within a script it would be converted
from unchecked to checked, without the script having to change anything
else while the same data as before flows to stdout and stderr.

Before anyone says "just check exit status" - we do but we're stuck with
certain underlying build tools which have unreliable status so we must
parse output as a belt-and-suspenders plan.

Does anyone know of such a module or something close to use as a
starting point?

-- 
Henry Townsend



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

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 7948
***************************************


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