[28646] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 10010 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 27 03:05:41 2006

Date: Mon, 27 Nov 2006 00:05:06 -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           Mon, 27 Nov 2006     Volume: 10 Number: 10010

Today's topics:
        Errors in Perl Function abhi147@gmail.com
    Re: handling hanging database connections: timeout in p xhoster@gmail.com
    Re: modPerl, Apache, and REMOTE_USER <trwww@sbcglobal.net>
    Re: my <nobull67@gmail.com>
        new CPAN modules on Mon Nov 27 2006 (Randal Schwartz)
    Re: Perl and Online Banking <bradbrockman@yahoo.com>
        pretty print to postscript (or pdf or tex) for both cod ivowel@gmail.com
    Re: pretty print to postscript (or pdf or tex) for both <bik.mido@tiscalinet.it>
    Re: pretty print to postscript (or pdf or tex) for both <someone@example.com>
    Re: prevent further hash auto-vivification <uri@stemsystems.com>
    Re: prevent further hash auto-vivification <cmic@caramail.com>
    Re: seek/tell in presence of multibyte characters <nobull67@gmail.com>
    Re: speaking of forking -- parallel database fetches? <DJStunks@gmail.com>
        test message - please ignore <user@example.net>
    Re: test message - please ignore krakle@visto.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 26 Nov 2006 21:17:27 -0800
From: abhi147@gmail.com
Subject: Errors in Perl Function
Message-Id: <1164604647.549947.214940@j72g2000cwa.googlegroups.com>

Hi all ,

 I have a shell script which has a small function to find previous
day's date , which is a perl function.
When I run this script on the command line , the script runs
successfully . Whereas when I run it as a cron job , it gives errors .

The perl function in the shell script is :

### To get yesterday's date ###
function get_yesterday {
    perl << "EOF"
    my ($mday, $mon, $year) = (localtime(time()-86400))[3,4,5];
    $mon++;
    $year += 1900;
    printf("%04d-%02d-%02d\n", $year, $mon, $mday);
EOF
}
yesterday=$(get_yesterday)

The errors encountered were :

$ ./test.sh
 ./test.sh: function: not found
2006-11-23
 ./test.sh: syntax error at line 15: `}' unexpected

Can anyone please tell me .. that do I need to do something extra to
run this script through crontab ?
 

Thanks



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

Date: 26 Nov 2006 19:24:46 GMT
From: xhoster@gmail.com
Subject: Re: handling hanging database connections: timeout in perl
Message-Id: <20061126142558.882$WO@newsreader.com>

daniel.crosby@gmx.de wrote:
> The script contains also the following information, i cannot see why
> the timeout would not be used when specified,

Heck, and I can't even see why that code would even compile, much less
why you would expect it to time anything out.


> some database connections
> just hang and do not timeout as they should per script.
>
> sub ConnectTimeOut {
> # ================================================================
>         my ($p_host, $p_db, $p_ars, $p_sev, $p_erg)=@_;
>         my @l_errstr = grep $DBI::errstr =~ m/$_/, keys
> %G_IGNORE_ORACLE_ERRORS;
>         $l_msg   = "$p_db Timeout  $G_CONF{TIMEOUT_DB_CONNECT} sec
> occurred conn
> ecting $p_db";
>         &Logging (0, $A, "timeout", $l_msg);

Where is the die statement?  Where is the closing bracket?

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 27 Nov 2006 05:19:44 GMT
From: "Todd W" <trwww@sbcglobal.net>
Subject: Re: modPerl, Apache, and REMOTE_USER
Message-Id: <Qzuah.12773$6t.7489@newssvr11.news.prodigy.com>


"Brian Wakem" <no@email.com> wrote in message 
news:4srnc3F10valiU1@mid.individual.net...
> snakedjip@yahoo.com wrote:
>
>> Hi,
>>
>> I use Xampp for my apache-mysql-modperl setup.
>>
>> I'm running a perl script from a directory that is protected with a
>> .htaccess file.
>>
>> I've setup apache to run as normal cgi if I access the file through
>> /cgi-bin/..., and to run as mod-perl if accessed from /perl/...
>>
>> If I run the script as normal cgi, I have access to $ENV{REMOTE_USER}
>> to identify my user.
>>
>> If I run the script as modPerl, that environment variable is not set.
>>
>> Is that due to some Xampp configuration in httpd.conf or elsewhere, or
>> is it just me that should know that $ENV{REMOTE_USER} is not set in
>> modPerl ?
>>
>> My question would then be : how do I know, in modPerl, what user is
>> accessing my script ?
>>
>> Thanks.
>
>
> $ENV{REMOTE_USER} *is* set in mod_perl.

Well, not by default, because mod_perl provides an API to the environment. 
Search at http://perl.apache.org/ for PerlPassEnv or something like that.

Todd W.




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

Date: 26 Nov 2006 12:14:19 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: my
Message-Id: <1164572059.653112.192480@l39g2000cwd.googlegroups.com>

Peter J. Holzer wrote:

> Even if it is internally implemented differently, I think the effect
> would be better described as:
>
>         therefore visible only within the loop.  Otherwise, the variable is
>         implicitly local to the loop and regains its former value upon exiting
>         the loop.  If the variable was previously declared with "my",
> 	the loop variable is also lexically scoped to the loop, as if
> 	it was preceded with the keyword "my".

Indded.  On several occasions in the past I've gone one stage further
and suggested that when this implicit my() happens Perl should emit a
warning.



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

Date: Mon, 27 Nov 2006 05:42:12 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Nov 27 2006
Message-Id: <J9DJuC.10F8@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Acme-DarmstadtPM-TieHash-0.3
http://search.cpan.org/~reneeb/Acme-DarmstadtPM-TieHash-0.3/
a module that shows that Perl can do all the Ruby things ;-)
----
Acme-PM-Erlangen-SteffenW-BuildTest-0.002
http://search.cpan.org/~steffenw/Acme-PM-Erlangen-SteffenW-BuildTest-0.002/
create a CPAN Module using Module::Build on Win32-Systems
----
Catalyst-Helper-Graphics-0.1
http://search.cpan.org/~jshirley/Catalyst-Helper-Graphics-0.1/
----
Class-Accessor-0.30
http://search.cpan.org/~kasei/Class-Accessor-0.30/
Automated accessor generation
----
Class-MOP-0.37_001
http://search.cpan.org/~stevan/Class-MOP-0.37_001/
A Meta Object Protocol for Perl 5
----
DBD-TimesTen-0.04
http://search.cpan.org/~wagnerch/DBD-TimesTen-0.04/
TimesTen Driver for DBI
----
DBIx-OO-v0.0.4
http://search.cpan.org/~mishoo/DBIx-OO-v0.0.4/
Database to Perl objects abstraction
----
Daizu-0.3
http://search.cpan.org/~geoffr/Daizu-0.3/
class for accessing Daizu CMS from Perl
----
DateTime-Format-Natural-0.17
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.17/
Create machine readable date/time with natural parsing logic
----
File-HStore-0.09
http://search.cpan.org/~adulau/File-HStore-0.09/
Perl extension to store files on a filesystem using a very simple hash-based storage.
----
Geo-Ellipsoids-0.02
http://search.cpan.org/~mrdvt/Geo-Ellipsoids-0.02/
Standard perl Geo package for Ellipsoids a and f (and invf) values.
----
Geo-Ellipsoids-0.03
http://search.cpan.org/~mrdvt/Geo-Ellipsoids-0.03/
Standard perl Geo package for Ellipsoids a and f (and invf) values.
----
Geo-Ellipsoids-0.04
http://search.cpan.org/~mrdvt/Geo-Ellipsoids-0.04/
Standard perl Geo package for ellipsoids a, b, f and 1/f values.
----
Geo-Gpx-0.13
http://search.cpan.org/~andya/Geo-Gpx-0.13/
Create and parse GPX files.
----
Geo-Gpx-v0.12.0
http://search.cpan.org/~andya/Geo-Gpx-v0.12.0/
Create and parse GPX files.
----
Geo-Lookup-ByTime-v0.0.1
http://search.cpan.org/~andya/Geo-Lookup-ByTime-v0.0.1/
Lookup location by time
----
Inline-CPP2XS-0.08
http://search.cpan.org/~sisyphus/Inline-CPP2XS-0.08/
This module is deprecated. Please install the latest version of InlineX::CPP2XS.
----
InlineX-C2XS-0.10
http://search.cpan.org/~sisyphus/InlineX-C2XS-0.10/
Convert from Inline C code to XS.
----
InlineX-CPP2XS-0.10
http://search.cpan.org/~sisyphus/InlineX-CPP2XS-0.10/
Convert from Inline C++ code to XS.
----
Kwalify-1.08
http://search.cpan.org/~srezic/Kwalify-1.08/
Kwalify schema for data structures
----
List-Pairwise-0.22
http://search.cpan.org/~tdrugeon/List-Pairwise-0.22/
map/grep arrays and hashes pairwise
----
Locale-SubCountry-1.38
http://search.cpan.org/~kimryan/Locale-SubCountry-1.38/
convert state, province, county etc. names to/from code
----
Moose-0.18_001
http://search.cpan.org/~stevan/Moose-0.18_001/
A complete modern object system for Perl 5
----
Net-GPSD-Server-Fake-0.08
http://search.cpan.org/~mrdvt/Net-GPSD-Server-Fake-0.08/
Provides a Fake GPSD daemon server test harness.
----
Net-SSL-ExpireDate-1.02
http://search.cpan.org/~hirose/Net-SSL-ExpireDate-1.02/
obtain expiration date of certificate
----
Net-Write-1.00
http://search.cpan.org/~gomor/Net-Write-1.00/
a portable interface to open and send raw data to network
----
Perl-Metrics-Simple-0.021
http://search.cpan.org/~matisse/Perl-Metrics-Simple-0.021/
Count packages, subs, lines, etc. of many files.
----
PerlInterp-0.04
http://search.cpan.org/~bmorrow/PerlInterp-0.04/
----
Regexp-Assemble-0.28
http://search.cpan.org/~dland/Regexp-Assemble-0.28/
Assemble multiple Regular Expressions into a single RE
----
SOAP-Amazon-S3-0.02
http://search.cpan.org/~karjala/SOAP-Amazon-S3-0.02/
A module interfacing with Amazon S3 through SOAP
----
SOAP-Amazon-S3-0.022
http://search.cpan.org/~karjala/SOAP-Amazon-S3-0.022/
A module for interfacing with Amazon S3 through SOAP
----
WWW-Module-1.00
http://search.cpan.org/~nwetters/WWW-Module-1.00/
use modules from CPAN without installing
----
Wx-0.64
http://search.cpan.org/~mbarbon/Wx-0.64/
interface to the wxWidgets cross-platform GUI toolkit
----
Wx-Demo-0.05
http://search.cpan.org/~mbarbon/Wx-Demo-0.05/
the wxPerl demo
----
XML-MyXML-0.051
http://search.cpan.org/~karjala/XML-MyXML-0.051/
A simple XML module
----
XML-MyXML-0.052
http://search.cpan.org/~karjala/XML-MyXML-0.052/
A simple XML module


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 26 Nov 2006 15:29:44 -0800
From: "banker123" <bradbrockman@yahoo.com>
Subject: Re: Perl and Online Banking
Message-Id: <1164583784.648499.289540@j72g2000cwa.googlegroups.com>

Thank for the post, I have been able to write code using mechanize.  I
am able to navigate to https://mail.yahoo.com/ sign on and return a web
page from which I parsed the number of e-mails I have.  I am now
working on the bank sign-on which seems to be a little more
challenging, thanks for pointing me in the right direction.



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

Date: 26 Nov 2006 15:55:21 -0800
From: ivowel@gmail.com
Subject: pretty print to postscript (or pdf or tex) for both code and pod
Message-Id: <1164585321.093714.137790@l12g2000cwl.googlegroups.com>


dear perl experts:  yes, I have read the perlfaq, part 3.  alas, I
would like something that prints nicely like the enscript perl mode,
but with the pod comments formatted nicely.  when I use enscript
-Eperl, the pod comments are just text, not nicely formatted.  does a
combined pretty-printer exist?

sincerely,

/iaw



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

Date: Mon, 27 Nov 2006 08:48:16 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: pretty print to postscript (or pdf or tex) for both code and pod
Message-Id: <tr5lm2lsopk8iqu529mghc6kpbq4v3sklq@4ax.com>

On 26 Nov 2006 15:55:21 -0800, ivowel@gmail.com wrote:

>dear perl experts:  yes, I have read the perlfaq, part 3.  alas, I
>would like something that prints nicely like the enscript perl mode,
>but with the pod comments formatted nicely.  when I use enscript
>-Eperl, the pod comments are just text, not nicely formatted.  does a
>combined pretty-printer exist?

I don't know enscript, but as a big LaTeX aficionado I would go that
route, with the listings package. I've not done that on a much regular
basis, but when I tried I found it impressive. But it depends on what
you really want to do: IIUC you want to print code as code and pod
*rendered*? Then I doubt it handles that. I can imagine ways to
achieve the effect, but I'm not even really sure whether I want it:
source code is source code and rendered documentation is, well, ehm,
rendered documentation.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Mon, 27 Nov 2006 00:47:05 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: pretty print to postscript (or pdf or tex) for both code and pod
Message-Id: <dAqah.19725$1U5.16698@edtnps90>

ivowel@gmail.com wrote:
> dear perl experts:  yes, I have read the perlfaq, part 3.  alas, I
> would like something that prints nicely like the enscript perl mode,
> but with the pod comments formatted nicely.  when I use enscript
> -Eperl, the pod comments are just text, not nicely formatted.  does a
> combined pretty-printer exist?

perltidy --html your_perl_program

And then convert that to postscript or whatever.


perldoc perltidy


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall


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

Date: Sun, 26 Nov 2006 23:23:16 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: prevent further hash auto-vivification
Message-Id: <x7y7px34cr.fsf@mail.sysarch.com>

>>>>> "BM" == Ben Morrow <benmorrow@tiscali.co.uk> writes:

  BM> Quoth Uri Guttman <uri@stemsystems.com>:
  >> >>>>> "BM" == Ben Morrow <benmorrow@tiscali.co.uk> writes:
  >> 
  >> 
  BM> As of 5.9 fields.pm is implemented in terms of locked hashes instead of
  BM> phashes. This is what they were added to perl for: to keep the
  BM> 'attribute checking' nature of phashes, which was deemed to be a benefit
  BM> of using fields.pm.
  >> 
  BM> IOO don't use locked hashes; but as of 5.10 they will (or can, anyway)
  BM> use Anno's new 'fieldhashes', which cope correctly with
  BM> threads/overloading/re-blessing.
  >> 
  >> i tend to not use much inheritance as i prefer delegation in
  >> general. objects owning objects makes more sense to me than objects
  >> being a variant of another object. with delegation you don't worry about
  >> sharing attributes and you should have no issues with those last issues
  >> you mentioned.

  BM> Threads and GC will still be an issue. When a variable is cloned to
  BM> create a new thread, its refaddr changes, so you need a CLONE method to
  BM> deal with that; and when a variable is destroyed its fields will not be,
  BM> so you need a DESTROY method to handle that. Fieldhashes handle both
  BM> those cases for you, cleanly.

all these side issues are why i push event loops over threads. but
enough of that for now.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 26 Nov 2006 22:55:05 -0800
From: "cmic" <cmic@caramail.com>
Subject: Re: prevent further hash auto-vivification
Message-Id: <1164610505.437371.289220@l12g2000cwl.googlegroups.com>

Hello.
ivowel@gmail.com a =E9crit :

> thank you, everybody.  Ben---this was exactly what I wanted.

I'm sorry to a bit too late. Can I add something (and forgive me if it
I'm wrong 8-)  )
There is a module called Tie::Hash::FixedKeys which can do the work for
you. If you try to insert a key which is not "authorized", Perl will
throw a run-time warning.

http://www.annocpan.org/~DAVECROSS/Tie-Hash-FixedKeys-1.10/lib/Tie/Hash/Fix=
edKeys.pm

Not tested, though.
--
cmic just another Perl user (not a Guru)

>
> Regards,
>
> /iaw
>
>
> Ben Morrow wrote:
> > Quoth ivowel@gmail.com:
> > >
> > > dear perl experts:  how can I stop perl from auto-vivifying new keys =
in
> > > a hash?  this seems like something that everyone would want as an
> > > optional feature in an object oriented context, isn't it?  sincerely,
> >
> > As of 5.8.0 you can use Hash::Util::lock_keys to prevent new hash keys
> > from being added in any way (including autoviv). This feature was added
> > to support OOP, IIRC (it is a replacement for the deprecated pseudohash
> > semantics).
> >
> > Ben
> >
> > --
> > Raise your hand if you're invulnerable.
> >                                                   [benmorrow@tiscali.co=
 .uk]



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

Date: 26 Nov 2006 12:41:48 -0800
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: seek/tell in presence of multibyte characters
Message-Id: <1164573708.611642.11400@h54g2000cwb.googlegroups.com>


Robert Dodier wrote:
> Brian McCauley wrote:
>
> > Robert Dodier wrote:
> >
> > > I would like to call seek and tell on files which contain multibyte
> > > characters (utf8).
> > > perldoc -f seek says that seek only considers byte offsets, not
> > > character offsets.
> > > How can I implement a seek-like function which takes a character
> > > offset?
> >
> > Why? No, seriously, why?
>
> To find a location in the file specified as the number of characters
> from the beginning.

I asked why not what.

> You may wish to consider that I want what I asked for.

I am happy to consider all possibilities.

Are you prepared to consider that this may be X-Y?



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

Date: 26 Nov 2006 19:06:44 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: speaking of forking -- parallel database fetches?
Message-Id: <1164594641.902847.111090@j72g2000cwa.googlegroups.com>

DJ Stunks wrote:
> Rocco Caputo wrote:
> > On 24 Nov 2006 11:23:27 -0800, DJ Stunks wrote:
> > >
> > > I have two straightforward SELECT statements, but both take about two
> > > minutes to complete.  I'd like to run them in parallel, but I obviously
> > > need access to all the rows - what's the best way to do so?
> > [...]
> > > Any ideas or maybe modules which could be handy? (I looked at both
> > > Acme::Spork and Parallel::ForkManager but neither are appropriate)
> >
> > There are four ways to do this with POE.  Whether they're appropriate
> > is left as an exercise. :)
> >
> > http://search.cpan.org/search?query=POE+DBI&mode=dist
>
> this looks great, time to start reading :-)

Well, I went with EasyDBI which looks ideal, however, my queries are
both coming back with the error "Died".  The queries work through
straight DBI, and both of them take the right amount of time through
EasyDBI, but no rows return, just the error.

I'm not sure if anyone is familiar with this module.  It doesn't look
like I can get any more detailed debugging as to what "Died".  I'll try
one of the other 4 suggestions tomorrow and see how it goes.

If it matters, the queries use the DBD::ODBC driver and I'm running on
Win32 (ActiveState Perl 5.8.7 [813], DBD::ODBC 1.13, POE 0.9500,
EasyDBI 1.14)

Thanks for the suggestion though, I'll keep at it.
-jp



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

Date: Sun, 26 Nov 2006 19:38:00 -0500
From: John Smith <user@example.net>
Subject: test message - please ignore
Message-Id: <ekdc0t$foc$1@news.ndhu.edu.tw>

test message - please ignore


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

Date: 26 Nov 2006 16:56:33 -0800
From: krakle@visto.com
Subject: Re: test message - please ignore
Message-Id: <1164588993.572128.41450@n67g2000cwd.googlegroups.com>



On Nov 26, 6:38 pm, John Smith <u...@example.net> wrote:
> test message - please ignore

Believe it or not (you obviously don't) there are forums dedicated for
testing purposes... You should visit there or better yet, unplug your
computer...



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

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


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