[21877] in Perl-Users-Digest
Perl-Users Digest, Issue: 4081 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 7 18:07:04 2002
Date: Thu, 7 Nov 2002 15:05:12 -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 Thu, 7 Nov 2002 Volume: 10 Number: 4081
Today's topics:
Re: A vision for Parrot (Alan Green)
converting cgi scripts to java <member@dbforums.com>
Re: file order in opendir DH <goldbb2@earthlink.net>
Re: file order in opendir DH <tassilo.parseval@post.rwth-aachen.de>
Re: How to guarantee process ID stays with web connecti <joe@amrita.net>
Re: How to guarantee process ID stays with web connecti <joe@amrita.net>
Re: How to guarantee process ID stays with web connecti <joe@amrita.net>
Re: Is it wrong to store method definitions in a databa <goldbb2@earthlink.net>
Re: log files for previous month <krahnj@acm.org>
Re: Makefile.PL @INC PREFIX LIB [should be How do I kee <mothra@nowhereatall.com>
Opening PPT WIn32:OLE <lance@augustmail.com>
Re: Perfecting my Perl <nobody@noplace.com>
Re: Perfecting my Perl <nobody@noplace.com>
Re: Perfecting my Perl (remove the obvious)
Re: Perfecting my Perl <goldbb2@earthlink.net>
Re: performance characteristics of embedded perl? <pkent77tea@yahoo.com.tea>
Re: perl ldap and MS-Active Directory or Netmeeting <pkent77tea@yahoo.com.tea>
Re: Safety of Perl <pkent77tea@yahoo.com.tea>
script to modify database table as different user <tech7890@yahoo.com>
Re: seconds -> hours/min/secs <krahnj@acm.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 7 Nov 2002 13:28:25 -0800
From: web.mail@lycos.com (Alan Green)
Subject: Re: A vision for Parrot
Message-Id: <270c68fe.0211071328.49f8abd@posting.google.com>
Daniel Pfeiffer <occitan@esperanto.org> wrote in message news:<20021105221004.339206f3.occitan@esperanto.org>...
> Hi,
>
> this morning it struck me that it would be nice to have Parrot not only run
> Perl 6 and similar byte code, but that any of the common interpreted languages
> be compiled to this same byte code.
Is it just me, or does anyone else think it peculiar that someone
'@esperanto.org' is championing a unified approach to language?
Daniel, is this part of a scheme to bring Python, Perl, TCL, Ruby
programmers around to your way of thinking?
;)
a
------------------------------
Date: Thu, 07 Nov 2002 18:42:41 +0000
From: anekwe <member@dbforums.com>
Subject: converting cgi scripts to java
Message-Id: <2021470.1036694561@dbforums.com>
looking for instructions on how to completely convert a perl cgi to java
--
Posted via http://dbforums.com
------------------------------
Date: Thu, 07 Nov 2002 16:36:11 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: file order in opendir DH
Message-Id: <3DCADCCB.C8AA779@earthlink.net>
Chris Harris wrote:
>
> Thanks go everyone who replied. I have the anser now.
>
> Last time I programmed anything was using C many years ago and there
> were no handy sort routines then, you had to do it all yourself, I
> thought there must have been something suitable in Perl, which seems
> to have everything built in :-)
This is rather OT for perl, but doesn't C have qsort()?
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 7 Nov 2002 21:37:16 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: file order in opendir DH
Message-Id: <aqemec$s97$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Benjamin Goldberg:
> Chris Harris wrote:
>>
>> Thanks go everyone who replied. I have the anser now.
>>
>> Last time I programmed anything was using C many years ago and there
>> were no handy sort routines then, you had to do it all yourself, I
>> thought there must have been something suitable in Perl, which seems
>> to have everything built in :-)
>
> This is rather OT for perl, but doesn't C have qsort()?
Yup, to be found in stdlib.h. It has very similar semantics to Perl's
sort taking a pointer to the beginning of an array, some adminstrative
arguments and a pointer to a function returning either -1, 0 or 1.
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Thu, 7 Nov 2002 14:26:19 -0600
From: "Joe Moschak" <joe@amrita.net>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <aqei9s$hpf$1@ins22.netins.net>
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrnasjqd0.2kt.mgjv@verbruggen.comdyn.com.au...
> On Wed, 6 Nov 2002 12:31:12 -0600,
> Joe Moschak <joe@amrita.net> wrote:
> > Every time I invoke a perl script from a web page, I get a different
process
> > ID (PID) and consequently different values for any variables. How can I
> > make it so that each time I invoke my script from a given web session I
get
> > the same PID instead of a different one? Below is code I use to verify
that
> > I get different PIDs each time.
>
> This question has nothing whatsoever to do with Perl.
>
> Why do you think you need the same pid every time?
>
> If you need some persistency in data or some sort of "session"
> management id, there are many ways to achieve that with webbie stuff
> without needing a pid. There are other groups that talk about this
> sort of stuff, in the comp.infosystems.www.* hierarchy. I am sure
> there are Perl modules available on CPAN to do this as well.
I'm now looking into Apache::Session. I thought it was part of mod_perl
(http://perl.apache.org/dist/mod_perl-1.0-current/apache-modlist.html#module
s) but even though I have mod_perl 1.26 installed my program keeps balking
Can't locate Apache/Session/File.pm in @INC (@INC contains:
/usr/home/builder/psa_503_patch/psa/release/dist/usr/local/psa/apache/lib/si
te_perl/5.00503/i386-freebsd
/usr/local/psa/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/psa/lib/perl5/site_perl/5.005 /usr/libdata/perl/5.00503/mach
/usr/libdata/perl/5.00503 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005 . /usr/local/psa/apache/
/usr/local/psa/apache/lib/perl)
when I try to use Apache::Session. Perhaps mod_perl does not automatically
include all the modules I see listed at
http://perl.apache.org/dist/mod_perl-1.0-current/apache-modlist.html#modules
> Since you don't actually tell us what it is you are trying to achieve,
> there is very little concrete help anyone can offer.
I inherited a shopping cart program that ran fine for 3 years on a server.
For some reason it did not appear to need any session management as provided
by, say Apache::Session. When I moved the code with no changes over to a
new server I noticed variables were getting all messed up. This was most
obvious when hitting the "recalculate" button and seeing a different
shopping list (held in an array) every time. I traced the problem to the
fact that every time I invoked my perl program, it retrieved a different
instance of it. A different PID. It'd be one thing if it consistently got
a new PID in which all the variables were empty, but it seems to retrieve a
previously used PID or new PID at random. So as often as not I'd get
variables from another web session. So all I'm trying to do is to get it
back the way it was. Failing that, I'll try to add better session
management.
>
> If you still think you do need a stable pid, write a server process,
> and have your CGI processes connect to that server process. Of course,
> whenever the server process restarts, the pid will most likely change.
>
> It is hardly ever useful to worry about the pid your process has.
>
> Martien
> --
> |
> Martien Verbruggen | If at first you don't succeed, destroy all
> Trading Post Australia | evidence that you tried.
> |
------------------------------
Date: Thu, 7 Nov 2002 14:37:59 -0600
From: "Joe Moschak" <joe@amrita.net>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <aqeivo$lk1$1@ins22.netins.net>
"Mina Naguib" <spam@thecouch.homeip.net> wrote in message
news:3DC968C1.7060009@thecouch.homeip.net...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Joe Moschak wrote:
> | Every time I invoke a perl script from a web page, I get a different
> process
> | ID (PID) and consequently different values for any variables. How can I
> | make it so that each time I invoke my script from a given web session
> I get
> | the same PID instead of a different one? Below is code I use to
> verify that
> | I get different PIDs each time.
>
> I think you're misunderstanding what a PID is.
>
> In the world of server-side web scripting, there is something called
> "sessions". A session is the server's attempt at tracking an invididual
> user for the duration of their visit. This can be done by the web
> server software itself (Apache/IIS/etc) or by the CGI code itself (your
> perl script). It's method of implementation is different, some use
> client-side cookies, some use IP addresses, etc... If sessions are set
> up right, you will get the same session ID for all invocations.
>
> PIDs (Process IDs), however, have nothing to do with the web server or
> your perl script. PIDs happen on the Operating System level. Every
> time a new process starts, the operating system gives it a new, unique
> PID. PIDs are how your operating system distinguishes between different
> processes.
>
> When your web server wants to run your CGI, it runs a new perl process,
> therefore getting a new PID.
>
> As a matter of fact, people often use the PID + time as a method to come
> up with a unique number. You're trying to do the exact opposite, which
> is the wrong way to go about it.
>
> My advice is to look into "sessions". CPAN seems to have a handful of
> modules at http://search.cpan.org/search?query=session&mode=all
>
Thanks for pointing me in the direction of session management. After poking
around some, I found Apache::Session. I thought it was part of mod_perl
(http://perl.apache.org/dist/mod_perl-1.0-current/apache-modlist.html#module
s) but even though I have mod_perl 1.26 installed my program keeps balking
Can't locate Apache/Session/File.pm in @INC (@INC contains:
/usr/home/builder/psa_503_patch/psa/release/dist/usr/local/psa/apache/lib/si
te_perl/5.00503/i386-freebsd
/usr/local/psa/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/psa/lib/perl5/site_perl/5.005 /usr/libdata/perl/5.00503/mach
/usr/libdata/perl/5.00503 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005 . /usr/local/psa/apache/
/usr/local/psa/apache/lib/perl)
when I try to "use Apache::Session". Perhaps mod_perl does not
automatically include all the modules I see listed at
http://perl.apache.org/dist/mod_perl-1.0-current/apache-modlist.html#modules
More likely it has something to do with the line commented out below in my
server's httpd.conf:
##
## mod_perl Support
##
#PerlSetEnv PERL5LIB
/usr/local/psa/apache/lib/perl/5.00503/:/usr/local/psa/apache/lib/perl/site_
perl/5.005/
I'm trying to get my sys admin to un-comment this out.
> Best of luck.
>
> -----BEGIN xxx SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQE9yWjBeS99pGMif6wRAssjAKDat0M+sfC01xFvoZvll+tv0oE/jgCg4Zry
> ZwFGGfpTHC/EEUma+6NgJ7w=
> =57tY
> -----END PGP SIGNATURE-----
>
------------------------------
Date: Thu, 7 Nov 2002 14:42:47 -0600
From: "Joe Moschak" <joe@amrita.net>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <aqej8q$s5u$1@ins22.netins.net>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:sBly9.9289$Wf5.5017@nwrddc04.gnilink.net...
> Joe Moschak wrote:
> > Every time I invoke a perl script from a web page, I get a different
> > process ID (PID) and consequently different values for any variables.
> > How can I make it so that each time I invoke my script from a given
> > web session I get the same PID instead of a different one?
>
> GRIIINNNN, this is a good one.
> You are getting a new PID because the web server starts a new process
every
> time.
> This is the way web servers work. How could they possibly do it any
> different? The process from the previous invocation may still be active.
I inherited a shopping cart program that ran fine for 3 years on a server.
When I moved the code with no changes over to a new server I noticed
variables were getting all messed up. This was most obvious when hitting
the "recalculate" button and seeing a different shopping list (held in an
array) every time. I traced the problem to the fact that every time I
invoked my perl program, it retrieved a different instance of itself. A
different PID. It'd be one thing if it consistently got a new PID in which
all the variables were empty, but it seems to retrieve a previously used PID
or new PID at random. So as often as not I'd get variables from another web
session. Not only that, nothing seems to kill off the old PIDs once a web
session is over with. So I'm trying to get it back the way it was. Failing
that, I'll try to add better session management.
> Should they create a new process for the second invocation with the same
> process ID as the first one? Just impossible.
>
> jue
>
> BTW: none of this is related to Perl in any way.
>
>
------------------------------
Date: Thu, 07 Nov 2002 16:21:06 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Is it wrong to store method definitions in a database?
Message-Id: <3DCAD942.ECB4FF26@earthlink.net>
Bryan Castillo wrote:
>
> > First possible re-think: If you can add cron jobs any time you
> > want, how about you specifically schedule the cron job to run at the
> > time of the first scheduled collection (as a kind of once-only cron
> > job).
> >
>
> I would think the at command(s) would make better sense then cron in
> this situation.
Possibly... I'm on windows, so I don't really know as much as I'd like
about those.
> > That is, have your Perl cron job only run when there *is* a job
> > scheduled, rather than frequently running, checking for jobs, and
> > then exiting due to not finding any to run.
>
> Using cron you would have to remove the entry once the job was done.
> And I would think you would be trying to do that programmatically.
> I've never considered editing crontabs programmatically, I would think
> you would run into sync. issues. Isn't the crontab a single file
> entry?
>
> At should be simpler to manipulate from perl also, than cron.
>
> Opinions?
While I've no comments on how easy 'at' is to manipulate, there are a
number of modules for editing 'cron' files.
http://search.cpan.org/search?query=-cron&mode=dist
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Thu, 07 Nov 2002 22:38:36 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: log files for previous month
Message-Id: <3DCAEB3F.7CE35898@acm.org>
robertbu wrote:
>
> I'm new to perl, so the test program below is probably not
> "good perl," but it provides you a starting point.
>
> == Rob ==
>
> use Time::Local;
> use warnings;
use strict;
> %hshMonths = ("Jan" => 1,
> "Feb" => 2,
> "March" => 3,
> "April" => 4,
> "May" => 5,
> "June" => 6,
> "July" => 7,
> "Aug" => 8,
> "Sept" => 9,
> "Oct" => 10,
> "Nov" => 11,
> "Dec" => 12
> );
Why are Jan, Feb, Aug, Oct, Nov and Dec abreviated to three letters but
Sept abreviated to four and March, April, June and July not abreviated
at all? Does this reflect the actual data?
> $SecondsInSevenDays = 7*24*60*60;
> @arNow = localtime time;
> $timeNow = timelocal(0,0,0,$arNow[3],$arNow[4]+1,$arNow[5]+1900);
^^^^^^^^^^^
This is not going to give you the correct time (same with the hash
above.)
perldoc Time::Local
[snip]
These routines are the inverse of built-in perl fuctions
localtime() and gmtime().
[snip]
It is worth drawing particular attention to the expected
ranges for the values provided. While the day of the
month is expected to be in the range 1..31, the month
should be in the range 0..11. This is consistent with the
values returned from localtime() and gmtime().
[snip]
Strictly speaking, the year should also be specified in a
form consistent with localtime(), i.e. the offset from
1900.
But why convert the output of time() to an array and then back to
seconds?
my $timeNow = time;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 7 Nov 2002 13:20:36 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: Makefile.PL @INC PREFIX LIB [should be How do I keep my own module/library directory?]
Message-Id: <3dcad8db$1@usenet.ugs.com>
> No. That's too easy. This only works for "normal" Perl programs.
[snipped]
Please read the documentation that I have pointed to:
$ pwd
/home/hillr/HTML-Parser-3.13
$ /app/perl5.8.0/bin/perl Makefile.PL PREFIX=/home/hillr/mymodules
Perl-5.6 provide experimental core support for Unicode strings. You
can compile HTML::Entities so that Unicode entities like € and
€ are decoded into a string containing "\x{20AC}". If you
select no to the question below such entities will be left alone and
only entities in the Latin-1 range is decoded.
Do you want decoding on unicode entities? [no]
Checking if your kit is complete...
Looks good
Warning: prerequisite HTML::Tagset 3 not found.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Writing Makefile for HTML::Parser
$ export PERL5LIB=/home/hillr/mymodules/lib/site_perl
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$ /app/perl5.8.0/bin/perl Makefile.PL PREFIX=/home/hillr/mymodules
Perl-5.6 provide experimental core support for Unicode strings. You
can compile HTML::Entities so that Unicode entities like € and
€ are decoded into a string containing "\x{20AC}". If you
select no to the question below such entities will be left alone and
only entities in the Latin-1 range is decoded.
Do you want decoding on unicode entities? [no]
Writing Makefile for HTML::Parser
(note:NO ERRORS !!!)
$ make
cp lib/HTML/Entities.pm blib/lib/HTML/Entities.pm
etc ...
make test
PERL_DL_NONLAZY=1 /app/perl5.8.0/bin/perl "-MExtUtils::Command::MM"
"-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/api_version........ok
t/argspec-bad........ok
t/argspec............ok
t/cases..............ok
t/comment............ok
t/crashme............ok
etc....
> Note secondly that despite "normal" programs, using PREFIX or LIB with
"perl
> Makefile.PL" do NOT change @INC! Here is (again) the proof:
The only thing this proves is that you can't read the documentation that was
given
you.
[snipped]
> Writing Makefile for HTML::Parser
>
> What the core issue is I don't know. Maybe a MakeMaker problem.
>
> So the problem remains:
> How can I install HTML::Parse in /some/local/dir while it is dependent on
> HTML::Tagset also installed in a this local dir.
------------------------------
Date: Thu, 07 Nov 2002 16:37:15 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: Opening PPT WIn32:OLE
Message-Id: <pan.2002.11.07.22.37.15.302166.7730@augustmail.com>
I keep getting error? I start with Powerpoint open but no
presentation.
OLE exception from "Microsoft PowerPoint 2000":
Powerpoint could not open the file.
Win32::OLE(0.1403) error 0x80004005: "Unspecified error"
in METHOD/PROPERTYGET "Open" at openppt.pl line 11
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft PowerPoint';
$Win32::OLE::Warn=3;
# get already active Excel application or open new
my $PptApp = Win32::OLE->GetActiveObject('PowerPoint.Application')
|| Win32::OLE->new('PowerPoint.Application', 'Quit');
$PptApp->{Visible} = 1;
my $Presentation = $PptApp->Presentations->
Open({FileName=>'p:\\doc\\projects\\perl\\test.ppt'});
Lance
------------------------------
Date: Thu, 07 Nov 2002 20:08:44 GMT
From: "Gregory Toomey" <nobody@noplace.com>
Subject: Re: Perfecting my Perl
Message-Id: <01c2869a$e4140cc0$05b18b90@gmtoomey>
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in article
<aqe2n4$7eu$1@nets3.rz.RWTH-Aachen.DE>...
> The following posted on request sent in a personal mail from Cameron
> Dorey (her newsservice appears to be down):
>
> Gregory Toomey wrote:
>
> >
> > My solution:
> > Using the English language word list at www.wordlist.sourceforge.net/
,
>
>
> Is this the right URL? My computer cannot find it, and it looks like a
good
> site to test some things I'm doing.
Sorry its http://wordlist.sourceforge.net/
I use
"SCOWL (Spell Checker Oriented Word Lists) is a collection of word lists
split up in various sizes, and other categories, intended to be suitable
for use in spell checkers. However, I am sure it will have numerous other
uses as well. "
There are some 670,000 words if you add all the sublists together.
gtoomey
------------------------------
Date: Thu, 07 Nov 2002 20:13:20 GMT
From: "Gregory Toomey" <nobody@noplace.com>
Subject: Re: Perfecting my Perl
Message-Id: <01c2869b$890bcce0$05b18b90@gmtoomey>
Julia deSilva <jds@trumpetweb.co.uk> wrote in article
<xjty9.34449$xF.1116@news-binary.blueyonder.co.uk>...
> > Does somebody have a more elegant solution?
> >
> > gtoomey
>
> Try : "Get a Life !"
There are cash prizes. I used Perlt to solve a more complex transposition
cipher problem in the same magazine.
gtoomey
------------------------------
Date: Thu, 07 Nov 2002 21:17:12 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: Perfecting my Perl
Message-Id: <sLAy9.488$hK4.36750@bgtnsc05-news.ops.worldnet.att.net>
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:aqe2n4$7eu$1@nets3.rz.RWTH-Aachen.DE...
| The following posted on request sent in a personal mail from Cameron
| Dorey (her newsservice appears to be down):
|
| Gregory Toomey wrote:
|
| >
| > My solution:
| > Using the English language word list at
www.wordlist.sourceforge.net/ ,
|
|
| Is this the right URL? My computer cannot find it, and it looks like
a good
| site to test some things I'm doing.
|
Try this:
http://wordlist.sourceforge.net/
--Rick
------------------------------
Date: Thu, 07 Nov 2002 17:46:50 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perfecting my Perl
Message-Id: <3DCAED5A.92DF8D4A@earthlink.net>
nobull@mail.com wrote:
[snip]
> > Does somebody have a more elegant solution?
>
> That would, of course, depend on your elegance metric.
>
> while (<>) {
> print if /c/ && !/[^aceintv]/
> && !/([eintv]).*\1/ && !/([ac]).*\1.*\1/;
> }
>
> (The outer loop can be replaced by invoking perl with the -n switch).
I would replace each '.*' in the regexen with '.*?', for slightly
improved efficiency.
Also, perhaps a check for length() <= 9.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Thu, 07 Nov 2002 22:11:44 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: performance characteristics of embedded perl?
Message-Id: <pkent77tea-89D5AF.22114407112002@news-text.blueyonder.co.uk>
Somethign possibly relevant to the original poster...
In article <1036691442.460968@elaine.furryape.com>,
gorilla@elaine.furryape.com (Alan Barclay) wrote:
> In article <R4xy9.330$O71.11@rwcrnsc53>, Stan Murch <smurch@no.spam> wrote:
> >Background: a few months ago I started writing a program in C because it
> >needs to run fast. Specifically, it will be started many times serially
> >and thus startup time is critical. But I soon decided to prototype it in
> For example, if you've got a CGI, then making it a mod_perl module will
> avoid the fork(),exec(), giving much faster response times.
A software engineer rewrote, completely, a perl CGI application in C
(he's also an experianced C and C++ guy as well as perl). He used
apachebench to see how quick it went
Perl CGI: 1.5 requests/sec
C CGI: 2 requests/sec
mod_perl app: ~10 requests/sec (can't remember exactly).
Once any perl has been compiled it runs comparably as fast as C (because
all you're really doing is going from one opcode struct to another in
core), and this particular application did a few bits of file IO, making
the difference in execution speed even less marked. If you program is
CPU-bound you would probably see a bigger difference.
In any case, forking and execing a compiled binary, loading up libc.so,
etc etc all take their time. As does loading perl itself. Look for
places where you can make big wins, which of course all depends on your
exact application. But don't spend too much time doing optimization
either!
E.g. a little mod_perl application I wrote runs as fast or faster than
Apache serving server-parsed html pages.
> For a regular command line program, you might want to approach splitting
> it into two halfs, one half which runs as a daemon and does much of the work
> and a second half which grabs the arguments and passes them onto the daemon.
Hmm, reminds me of MRTG (perl) and rateup (C), and I think rateup was
originally written in perl, but it was speeded up by 40 times or
something by writing in C. The C program does a lot of crunching and the
perl program does all the tricky high-level stuff like marshalling
inputs, checking validity etc. I think, anyway.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Thu, 07 Nov 2002 22:14:04 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: perl ldap and MS-Active Directory or Netmeeting
Message-Id: <pkent77tea-DC3CCF.22140407112002@news-text.blueyonder.co.uk>
In article <3DCAB74E.A15C6BD7@t-online.de>,
Rainer Scherg <Rainer.Scherg@t-online.de> wrote:
> has anyone experience in accessing Microsofts
> Actiev Directory or Netmeeting (ils-Server) from perl
> with perl-ldap (from unix)?
I don't know if this is any use but soeone at work has managed to
interface very successfully with the LDAP server that's part of our
Exchange system (I'm hazy on the details but given a Windows login
username you can get all the data about the user from Exchange et al)
and they used the PHP LDAP stuff (some problems there) and teh perl LDAP
stuff (much better).
If you want I can find out a bit more
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Thu, 07 Nov 2002 22:21:57 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Safety of Perl
Message-Id: <pkent77tea-1039EF.22215707112002@news-text.blueyonder.co.uk>
In article <f98999c8.0211070510.71ec6f77@posting.google.com>,
jc_va@hotmail.com (Buck Turgidson) wrote:
> Does Perl have built-in safeguards that will protect me from myself in
> terms of over-writing memory, etc? Perl seems to be able to do what I
> want to do, and I am just wondering if it is also safer.
I'd say it's 'safer' in that you can just create arrays, strings etc and
not have to care about the memory allocation and all that - it's all
done for you. Sure, you usually remember to free() memory or bounds
check buffer arrays, but sometimes you just want to get on with coding.
Perl allows you to worry less about the low-level stuff and concentrate
on the problem at hand[1]
OTOH perl on Unix systems will try to allocate memory if you keep asking
it to (e.g. slurping huge files into a string) and it'll open files
until you run of file descriptors. Most interactive shells have features
to help stop this kind of thing. See the man page for 'ulimit' for
example.
P
[1] in general. and sometimes you _want_ the low level stuff, and all
that control, etc etc. use right tool for right job.
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Thu, 7 Nov 2002 14:46:46 -0500
From: "Andrew" <tech7890@yahoo.com>
Subject: script to modify database table as different user
Message-Id: <aqefr1$d0t$1@news.monmouth.com>
Hello perl.misc!
I am using perl 5.6 on a linux machine (2.4.9 kernel). Could someone
provide me with the common strategy for doing the following since suid bit
is not usable in linux unless wrapped in a c program:
I need to allow certain users to modify a database table in a postgresql
database through a simple program written in perl. However the user's
ability to modify the program must ONLY be through this perl program so the
user can not modify the db table from other areas. How is this restriction
generally achieved if the script can not be run by user X as user Y where Y
has the proper database permissions and X does not? I suppose the script
itself could change users but how is that safer?
Thank you for the time and for sharing your knowledge.
-----
Andrew
tech7890REMOVETHIS@yahoo.com
remove 'REMOVETHIS' chars from e-mail address above to e-mail me
------------------------------
Date: Thu, 07 Nov 2002 22:06:33 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: seconds -> hours/min/secs
Message-Id: <3DCAE3BF.60E48C47@acm.org>
Naran Hirani wrote:
>
> Is there some pre-built script that takes a large number of seconds and
> converts it
> into: hh:mh:sh format?
sub sec2format {join':',(gmtime$_[0])[2,1,0]}
John
--
use Perl;
program
fulfillment
------------------------------
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.
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 4081
***************************************