[15848] in Perl-Users-Digest
Perl-Users Digest, Issue: 3261 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 6 00:05:58 2000
Date: Mon, 5 Jun 2000 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960264309-v9-i3261@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 5 Jun 2000 Volume: 9 Number: 3261
Today's topics:
Re: BerkeleyDB Installation <larkas@eden.rutgers.edu>
Re: Can't Write Binary File <lr@hpl.hp.com>
Re: CRON + system <madmardy@madmardy.com>
Re: CRON + system <elaine@chaos.wustl.edu>
DBA looking for PERL script to show last modified date <schallert_nathan_C@lilly.com>
Re: DBA looking for PERL script to show last modified d (Randal L. Schwartz)
Re: DBA looking for PERL script to show last modified d (Steven Smolinski)
Re: easy reference question (Abigail)
Re: global chown ?? <anmcguire@ce.mediaone.net>
Help! perl cgi with Apache/Unix versus Netscape/NT <neil@mythologics.com.invalid>
Re: Help! perl cgi with Apache/Unix versus Netscape/NT <mikes@escape.com>
How to use single quote in Perl/CGI script? <cmou@vt.edu>
Re: IP/port check help wanted <hal9000@zonnet.nl>
Re: Multiple Threads Running Perl via Shared Lib - Poss <gresh@earthlink.net>
Re: Peculiar? Re-entrant Subroutines? (Randal L. Schwartz)
Re: Perl -VS- PHP (Randal L. Schwartz)
Re: Perl gurus: help a C++ programmer optimize his ways (Greg Schmidt)
Re: PERL JOBS (£40k+) (Randal L. Schwartz)
Re: Secure CGI session in Perl (Mark P.)
Sockets -- Packet at a time? <trev@hostyersite.com>
Re: Still a little puzzled (Was Re: Globbing with Activ <dan@tuatha.sidhe.org>
strict doesnt like array references <mc@backwoods.org>
Re: strict doesnt like array references <makarand_kulkarni@My-Deja.com>
Re: strict doesnt like array references <madmardy@madmardy.com>
Re: Stupid Question: scripts won't recognize opening li <phill@modulus.com.au>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 05 Jun 2000 22:20:49 -0400
From: Larry Kasoff <larkas@eden.rutgers.edu>
Subject: Re: BerkeleyDB Installation
Message-Id: <393C6001.A2E13EF8@eden.rutgers.edu>
"Aaron D." wrote:
> OK, I'm having a tough time with this and maybe somebody out there can
> point me in the right direction. I'm trying to install BerkeleyDB for
> Activestate Perl. Now usually I just copy the appropriate PM files and
> dir structure to my site/lib folder and off I go. Occasionally, I have
> to build the module on my Linux server and then move the built files
> over. I can't seem to get anything to work this time. I've tried:
>
> 1) On my linux server I tried the whole "perl Makefile.PL" routine and
> got an "undeclared variable" error while Make handled the XS file.
>
> 2) I tried to just copy the PM and XS files over straight, but of
> course, Autoloader can't find the XS routines it needs.
>
> 3) I was finally able to compile the C++/Java part after digging out my
> MSVC. But I'm not sure if those LIB files are in anyway necessary for
> the Perl build.
>
> I guess I'm just confused =) The documentation isn't terribly clear on
> this. I greatly appreciate your time and patience with my ignorance =)
>
> Cheers!
> Aaron Dalton
> <aarond@ieighty.net>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Use PPM when connected to the Internet.
In your perl directory, type ppm.
ppm
ppm>install DB_File
ppm>quit
This will install the module for use with ActiveState perl. Please note
that 'ppm>' is the prompt that ppm gives you after starting it.
------------------------------
Date: Mon, 5 Jun 2000 18:04:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Can't Write Binary File
Message-Id: <MPG.13a5ee0c510f880098ab26@nntp.hpl.hp.com>
In article <sjodstqs2t5137@corp.supernews.com> on Mon, 5 Jun 2000
16:31:12 -0700, Gabe <grichards@flashcom.net> says...
> The following results in a file name $picname being created but with zero
> bytes, i.e. no data is written to it. I can't figure it out. I've used this
> algorithm in other programs and it's worked...I think. Please help.
>
> #This code doesn't work;
> use CGI;
> use File::Basename;
> fileparse_set_fstype('MSWin32');
> my $file = $cgi->param('image');
> my $picname = basename($cgi->param('image'));
> no strict;
Why???
> open (PIC, ">/home/cremeco/www/images/$picname") or die &error;\
binmode $file;
binmode PIC;
> while (my $bytesread = read($file,my $buffer,1024)) {
But $bytesread isn't being used. Why assign to it?
> print PIC $buffer;
> }
> close PIC;
>
> The next snippet, from a different program, writes to the same server, but
> this one works, what's the difference! They're virtually the same program
> right?
There may be a difference in the input data. For example, a "\cZ" would
be considered as EOF, because you didn't binmode the input file.
Try it again, with the two binmode's.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 05 Jun 2000 21:12:16 -0600
From: Mark Holt <madmardy@madmardy.com>
Subject: Re: CRON + system
Message-Id: <393C6C0F.5B2314E@madmardy.com>
cron doesn't run with the same environment as your login. Specifically,
the PATH is a slimmed-down version. try specifying an absolute path to all
files and executables. Also make sure your script does a "chdir" into the
directory where you want to run it, as the cron will not necessarily run it
in its own directory.
JoeB wrote:
> Hello All,
>
> Can anyone tell me if I can call the "system" function in a cron job?
> My script runs fine from the command line. Hoewver, as a cron job
> it doesn't. I have managed to narrow it down to "system" function call.
> Any Help will be appreciated.
------------------------------
Date: Tue, 06 Jun 2000 04:02:58 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: CRON + system
Message-Id: <B561F02F.58D1%elaine@chaos.wustl.edu>
in article 8hha69$j6j$2@news.ycc.yale.edu, John Gehman at
jdg28@pantheon.yale.edu quoth:
> JoeB (joeb@jagas.demon.co.uk) wrote:
> : Hello All,
>
> : Can anyone tell me if I can call the "system" function in a cron job?
> : My script runs fine from the command line. Hoewver, as a cron job
> : it doesn't. I have managed to narrow it down to "system" function call.
> : Any Help will be appreciated.
> Perhaps what you're running from the command line is dependent on the
> directory that you're in? That is, some path that you've defined for use
> with the system("...","...") is defined in terms relative to the location
> of the executable? If so, specify the path with absolute referencing
> (that is /home/user/Directory/subdirectory/file )
Hmm?
When you run a program from your CLI, you have something called a SHELL
which has an ENVIRONMENT which has something called a PATH. Now, when cron
executes the program it doesn't have the same environment or path. On System
V systems [ solaris, irix, linux(most flavours), etc ] you will look in
/etc/default/cron which will tell you what your default path for cron is.
You may augment this path or, probably better, add a path into your script.
'perldoc perlrun' for how to use this ENV variable.
e.
------------------------------
Date: Mon, 05 Jun 2000 22:47:42 -0400
From: Nate Schallert <schallert_nathan_C@lilly.com>
Subject: DBA looking for PERL script to show last modified date with seconds
Message-Id: <393C664E.5CAA6336@lilly.com>
I am not a PERL coder, but have a need to list files, with their
associated last modified date, to include seconds. We only have a couple
of UNIX system administrators that know PERL and neither were familiar
with such a routine.
I would like the script to work on HP-UX and SUN Solaris. None of the
files I am concerned with existed prior to 1970 so I don't think the
epoch is a factor? I did scan headers, looking for my problem, but
didn't find the specifics. Any help you offer is greatly appreciated.
------------------------------
Date: 05 Jun 2000 19:52:50 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: DBA looking for PERL script to show last modified date with seconds
Message-Id: <m1itvno70d.fsf@halfdome.holdit.com>
>>>>> "Nate" == Nate Schallert <schallert_nathan_C@lilly.com> writes:
Nate> I am not a PERL coder, but have a need to list files, with their
Nate> associated last modified date, to include seconds. We only have
Nate> a couple of UNIX system administrators that know PERL and
Nate> neither were familiar with such a routine.
for (<*>) {
$time = localtime +(stat)[9];
printf "%-50s %s\n", $_, $time;
}
Next time, try something tough. :)
--
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: Tue, 06 Jun 2000 03:16:48 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: DBA looking for PERL script to show last modified date with seconds
Message-Id: <slrn8jor89.a5i.sjs@john.sympatico.ca>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Nate" == Nate Schallert <schallert_nathan_C@lilly.com> writes:
>Nate> I am not a PERL coder, but have a need to list files, with their
>Nate> associated last modified date, to include seconds. We only have
>Nate> a couple of UNIX system administrators that know PERL and
>Nate> neither were familiar with such a routine.
> for (<*>) {
> $time = localtime +(stat)[9];
> printf "%-50s %s\n", $_, $time;
> }
Randal, I expected something far less readable from you. And a temp
variable! Coddle us no more! At the very least, stick it on one line:
printf "%-50s %s\n", $_, scalar localtime +(stat)[9] for <*>;
Is it really true that hackers write more readable code as they mature?
Steve
------------------------------
Date: 6 Jun 2000 01:54:51 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: easy reference question
Message-Id: <8hhllb$ch2$1@news.panix.com>
On Mon, 5 Jun 2000 17:59:53 -0500, Tad McClellan <tadmc@metronet.com> wrote:
++
++ Perhaps you were thinking of square brackets when used for
++ _indexing_ an array, which gives scalar context?
No, indexing propagates context.
sub context {print wantarray ? "LIST\n" : "SCALAR\n"}
$foo [context];
@foo [context];
will print:
SCALAR
LIST
Abigail
------------------------------
Date: Mon, 5 Jun 2000 22:34:32 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: global chown ??
Message-Id: <Pine.LNX.4.21.0006052232230.22645-100000@hawk.ce.mediaone.net>
On 5 Jun 2000, Abigail wrote:
+ On Sun, 04 Jun 2000 15:15:23 +0200, frank <frank@french-connexion.com> wrote:
+ ++ I (linux newbie) am trying to write a script that chowns all the files
+ ++ and directories belonging to "sam" in the current directory to "joe" ?
+
+ No use for Perl here:
+
+ find . -user sam | xargs chown joe
The original question could also be interpreted such as to yield
an answer of:
find . -maxdepth 1 -user sam | xargs chown joe
Depending on precisely what he meant by the above quoted sentence.
Regards,
anm
--
/*-------------------------------------------------------.
| Andrew N. McGuire |
| anmcguire@ce.mediaone.net |
`-------------------------------------------------------*/
------------------------------
Date: Mon, 05 Jun 2000 22:26:51 -0400
From: Neil <neil@mythologics.com.invalid>
Subject: Help! perl cgi with Apache/Unix versus Netscape/NT
Message-Id: <393C616B.49A4@mythologics.com.invalid>
Help!
Perl cgi script that runs fine on Apache/Unix fails on Netscape/NT
webserver, apparently due to "malformed header".
A simple test script (called through the browser/web-server) that should
print a directory listing (using "\n" after each entry) seems to print
CR/CR/LF after each line, rather than the expected CR/LF pair. If that's
what is happening to my real program, I can see why it would fail to
produce valid HTML headers...
Is this some sort of known configuration problem with Netscape/NT that
I've encountered? (I have no experience with the Netscape/NT
combination). (The perl scripts were written on a Win95 machine, with
normal CR/LF pairs).
Thanks in advance
Neil
MythoLogics
------------------------------
Date: Mon, 05 Jun 2000 23:46:35 -0400
From: mike <mikes@escape.com>
Subject: Re: Help! perl cgi with Apache/Unix versus Netscape/NT
Message-Id: <393C741B.D4111C61@escape.com>
Hi Neil,
what is your Perl cgi script?
Mike
------------------------------
Date: Mon, 05 Jun 2000 22:04:26 -0400
From: Kevin Mou <cmou@vt.edu>
Subject: How to use single quote in Perl/CGI script?
Message-Id: <050620002204261830%cmou@vt.edu>
Hi,
I am trying to print a paragraph which contains a few single quotes
(not single quoted string) in Perl/CGI script. For example, student's,
user's, etc. I used student\'s, user\'s, but it does not seem to work
in the HTML response page.
What should I use to get the word, student's, to show up correctly in a
HTML page?
Please help!
Thanks in advance,
Kevin Mou
cmou@vt.edu
------------------------------
Date: Tue, 6 Jun 2000 03:42:11 +0100
From: "hal9000" <hal9000@zonnet.nl>
Subject: Re: IP/port check help wanted
Message-Id: <393c55c6_1@excalibur.gbmtech.net>
Net::Ping does the trick for me, I check a lot of hosts for availability
every couple of minutes. Also before I attempt to make any FTP connection I
ping the host to check if it's online (directly attempting an FTP connection
and getting some errorcodes back takes a long time if the host is
off-line)...
Hope this helps...
hal9000
<<< Small step for *NIX, giant leap for PC's >>>
Helza wrote in message <8hbq3i$85vhp$1@reader1.wxs.nl>...
<<<snip>>>
>How do i make a quick ip/port check to see if the server is online?
<<<snip>>>
------------------------------
Date: Tue, 06 Jun 2000 02:34:38 GMT
From: Guy Resh <gresh@earthlink.net>
Subject: Re: Multiple Threads Running Perl via Shared Lib - Possible? Safe?
Message-Id: <cjmojscrt9tr1hnc438i6tq1andad3p53a@4ax.com>
Currently, Perl 5.6 (and 5.005_03 for that matter) can be MADE to
support multiple concurrent threads, by either running a single
interpreter instance with multiple threads sharing the single instance
(i.e. configure USE_THREADS), or by using MULTIPLICITY, where each
thread runs with it's own interpreter instance. There are SEVERAL
nasties here with both of the above, not the least of which:
With USE_THREADS:
1) performance is less than "optimal" as there are several global
mutexes (sv_mutex comes to mind) that kill performance.
2) global variable/data access must be carefully mutexed around
(subroutines are global!)
3) there are a few instances where MT-safe versions of certain
functions weren't implemented (localtime_r/gmtime_r come to mind).
With MULTIPLICITY:
1) as currently implemented, there is a global pointer that indicates
which interpreter instance is currently "active", so only one thread
can actually be running at a time, lest they stomp on one another
#2 & #3 from USE_THREADS apply above as well...
I've spent the last year or so "fixing" the above (and a lot more!
:( ) with 5.005_03 & lately 5.6, for use at work & "play", including,
1) eliminating the need for sv_mutex & strtab_mutexes (each thread has
it's own "root-pool". All SVs, HVs, etc. are now thread-centric,
which probably goes against the current "desired" model, but it's what
I needed for embedding Perl into an NSAPI module within Netscape
Enterprise Server on Solaris 2.6. I also maintain separate
thread-centric memory blocks, so that hits to the heap are basically
eliminated once the server is up and running a few seconds. I can
serve 800+ dynamic PHTML pages each second on a 4x400 SPARC 450
(non-optimized, i.e. everything compiled with -g).
2) using MT-safe C functions where appropriate (localtime_r, etc.)
3) moving a lot of the interpreter-centric (interpvar.h) variables
over to the thread-centric ones (thrdvar.h) and eliminating
PERL_OBJECT defines/code since it's being deprecated anyway.
4) with 5.6, passing a Perl context EVERYWHERE (including the memory
management routines), eliminating the dTHR/dTHX overhead (which also
solves the #1 problem above with MULTIPLICITY.
I'm not an "official" Perl contributor (yet) as I'm not exacly sure
where my company stands on me turning my "MT expertise" back over into
the PD. If there's enough interest in others seeing what I've done, I
may be able to convince them. I'll also be attending the conference
in Monterey this year and so will be able to lend assistance there as
well if people are interested.
Note there are also other possible "permutations" for configuring
Perl (e.g. MULTIPLCITY & USE_THREADS at the same time), but they are
REALLY, REALLY, REALLY nasty to debug, and as I didn't need to have
more than one thread per interpreter instance/context, I haven't
bothered to see what's broken when trying to handle both at the same
time. "make test" passes all but a few (5 or 6?) tests that I haven't
bothered to debug yet with 5.6, but will over the next few weeks lest
my conscience get to me :).
So, basically, yes, it's been done; it's in production (with
5.005_03 currently) serving 100+ million requests each month :)
(what am I getting myself into...)
Regards,
Guy Resh
guy.resh@fmr.com
On Mon, 05 Jun 2000 20:34:51 GMT, nick@secant.com (Nick Knight) wrote:
>
>Hello,
>
>The basic question is, is Perl 5.6.0 thread safe? I have an application
>where I want to wrap Perl up in a shared library (Linux, WinNT, BSDI and
>maybe Solaris), then have my application be able to run scripts in a
>multithreaded manner. IOW, my app wants to create multiple threads with
>each thread capable of running a Perl script. It may be a bunch of
>different scripts, or the same script with different parameters in each
>thread.
>
>Now, I tried to research this via dejanews, and what I found were mixed
>signals. The closest I came to "an answer" was a post from 10/99 in which
>I read:
>
>>>I've tried to understand how I can use embedded perl in a multithread
>>>application and I'm a bit confused.
>>>We have a process in a multithread mode. This process is linked with an
>>>embedded perl library. Each thread starts its own perl interpreter. Is
>>>it safe to run several threads at the same time, where each thread is
>>>executing separate interpreters ?
>>
>>This isn't safe. You must protect perl with a global mutex and make
>>sure that only one thread is in any perl interpreter at any one
>>time. This may be safe in 5.6 (and only if you build with
>>threads) but it isn't now.
>>
>>And embedding a threaded perl isn't enough either, as perl
>>takes a mnumber of shortcuts if it thinks there's only one
>>thread running.
>
> ---
>
>This tells me what I want to do may not be feasible. Except, "may be safe
>in 5.6". Does anyone know for a fact? Has anyone done this?
>
>Thanks in advance!
>
>Nick
------------------------------
Date: 05 Jun 2000 19:45:14 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Peculiar? Re-entrant Subroutines?
Message-Id: <m1pupvo7d1.fsf@halfdome.holdit.com>
>>>>> "Paris" == Paris <odesseus@my-deja.com> writes:
Paris> if ($search_in =~ /$search_for/oi){$slice_ok = 1}else{last}
Paris> I decided that if I wanted to cross reference the results of this file,
Paris> against text taken from another file, I could do something like this...
You used /o. Stop that. It hurts. Read very carefully what /o does,
and you'll see that you need to stop that.
--
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: 05 Jun 2000 19:19:09 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl -VS- PHP
Message-Id: <m1zoozo8ki.fsf@halfdome.holdit.com>
>>>>> "jason" == jason <elephant@squirrelgroup.com> writes:
jason> MC writes ..
>> Does anyone know what advantages PHP has over Perl, both in general and for
>> CGI/Database processing??
jason> I'll go on record .. none
PHP is "training wheels without the bicycle".
Use at your own risk. It's great if you don't really want to be a
programmer, but tops out rather rapidly if you spend more than two
hours a week hacking code.
--
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: Tue, 06 Jun 2000 03:35:26 GMT
From: gregs@trawna.com (Greg Schmidt)
Subject: Re: Perl gurus: help a C++ programmer optimize his ways
Message-Id: <393c6768.174611045@news.mtmc1.on.wave.home.com>
On Mon, 5 Jun 2000 23:53:54 +0200, "Michael Schlueter"
<michael.schlueter@philips.com> wrote:
>* I'd #!/usr/local/bin/perl -w # to benefit from warnings
I had used that from the command line during debugging, but left it out of
the "production" code. It seemed at the time (although I don't remember
why, and I could be very wrong) that there were potential problems with
leaving it in.
>* Do you know the perl debugger perl -d film.pl ?
Thanks, didn't know that one. I'll give it a try.
>* local: do you need perls local mechanism (restoring the original variable
>after it goes out of scope)? Or did you intend my (a separate namespace for
>the entire scope; no restore as with local)? It looks like you know the
>difference. Why do you need local?
>
>* You use a lot of $main::something in subs. I never used that style. What
>is your intention? Do you want to access gloabal variables?
I had started off just using "bare" variables (ie. "$logfilename") as
globals, declared in the "main" section, and used in functions. "strict"
complained about this, and after some playing around, a change to "local
$main::logfilename" made the warnings disappear. In general, I don't like
global variables, but I like even less having to pass a half-dozen extra
parameters to every function I call. My guess at the right way to do this
would be to embed all such variables in an object and pass that, but I'm not
at that point yet in the learning curve. Are there other right ways of
doing it? (Likely a silly question, what with this being Perl we're talking
about. There's always several right ways, right?)
>* Date-operations in sub report: did you check http://search.cpan.org for
>other Date classes? Perhaps there is already a more elegant way do do it.
That part of the code was written before I knew about CPAN. And there are
so few lines (four, executed only once, to be precise) that I'm not
convinced it's worth learning a new module for.
>* Do you know about the HTML-modules from CPAN?
I am using CGI.pm, as you no doubt saw. Are there others that would be
useful in my application? Or did you mean something to replace CGI.pm? The
wealth of CPAN boggles me, as I've gone looking, without much success, for
similar things before (for C and C++). I feel like my dad must have when I
showed him how to cut-and-paste in Word -- he had no idea that this was even
possible, and so never asked how to do it.
>* Do you know chapter 8 "Other Oddments" from Programming Perl (O'Reilly)?
>It is dedicated to specific language traps when starting with Perl, Timing
>efficiency and other.
No, I haven't got there yet. I've made my way through most of "Learning
Perl", and have got "Programming" on the bookshelf but have only used it as
an occasional reference so far. And, to be honest, I've always learned much
better from trial-and-error than reading. But I will give this a look; a
glance at the ToC looks promising.
>Glancing through your code it is very difficult for me to tell you where the
>problem is. Do you know the contributions on timing from the CGI-calls (I
>mean more specific with respect to specific CGI-calls)?
There's a comment at the top of the file that indicates where I have tracked
the bulk of the time down to. I guess it wasn't prominent enough. Or did
you mean details on exactly how long each of the CGI calls takes? I did
some of this timing, although only enough to prove to myself that it is the
Tr and td calls (especially the ones that take arrays). For example,
td(' ') took (from memory) about twice as long as '<td> </td>'.
My hope was that someone might be able to look at these lines and say "Oh,
it's quite obvious that there are a million temporary objects being created
here that aren't needed." It is, on the other hand, entirely possible that
it just happens that CGI.pm really is that slow at the best of times.
> Was there a time
>when your program run quick enough? When did it turn to slow? What happened?
Well, before I rewrote the whole thing it was faster. It was also less
functional (a few relatively minor (in terms of performance) new features
that I added), and much harder to maintain (manually generating all HTML).
Plus there was no CSS, the HTML didn't quite validate correctly, and I've
changed the look, but that's neither here nor there as far as speed goes.
>Personally I would try to define a few more packages to outsource common
>tasks and to reuse code. I'd try to make the code less 'tricky'. Did you
>consider using Perl-objects, object modelling etc.?
As I said, I'm really just getting going. And I'm trying to learn CSS at
the same time, so that's slowing me down. Oh, and my paying job really gets
in the way. :-) Objects are, I believe, yet a little ways into my future.
I wasn't trying to do anything tricky; if there are such things, it's likely
that I simply don't understand the "Perl way". I would much appreciate any
pointers for improvement in style and clarity, as much as or more than tips
on how to speed the thing up. (Just to be clear, I don't expect anyone to
go through the whole shebang and correct everything I've done. If you (the
newsgroup denizens in general, not just the kind soul whose message I'm
replying to) are paging through and one or two things catch your eye, I'd be
terribly pleased to learn from any comments you care to make.)
>Good luck,
>Michael Schlueter
Thanks for the helpful comments. I'll try to be back in a couple of weeks
(likely read: couple of months) when I've had a chance to digest all the
information pointed to, and implemented some improvements.
--
Greg Schmidt (gregs@trawna.com)
Trawna Publications (http://www.trawna.com/)
Fiction Into Film List (http://www.trawna.com/gregs/movies/)
------------------------------
Date: 05 Jun 2000 19:44:09 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: PERL JOBS (£40k+)
Message-Id: <m1u2f7o7eu.fsf@halfdome.holdit.com>
>>>>> "Mark" == Mark P <perl@imchat.com> writes:
Mark> On 31 May 2000 23:33:04 GMT, dha@panix.com (David H. Adler) wrote:
Mark> They didn't read that, and they never will read the reply or stop
Mark> posting so your message has been a waste of time.
Mark> Unfortunate but true.....
Mark> Just ignore them!
Actually, I email the parent message to the one that Dave posts. About
half the time, I get an "up yours, Usenet nazi cop", and the other half
I get "Oh, I'm sorry, I didn't know about this... I won't do it
again in the future".
Dave posts his because we want the www.deja.com record to show that
this sort of post is objectionable, and that the objections are not
challenged. Other groups have failed to do this, and therefore lost
the ability to challenge on the history of the publicly available
record, which is sad.
--
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: Tue, 06 Jun 2000 01:56:31 GMT
From: perl@imchat.com (Mark P.)
Subject: Re: Secure CGI session in Perl
Message-Id: <393c56a8.226046177@news.ionet.net>
On Mon, 05 Jun 2000 10:54:49 +0800, Maciej Mastalarczuk
<maciek@treko.net.au> wrote:
>Thanks a lot for the reply. Certainly I tried to use .htaccess. The problem
>is that I am not sure whether this transmission is SSL secured. The user is
>propted to type in the password before the browser reports secure
>connection.
>Am I wrong?
If its posted to a secure server the transmission is
encrypted.
>
>Is there any way to diable caching of the page? I mean in the page (or
>CGI) source, not the browser of course.
Sure but then IE has to be dealt with again because it seems
to do what it wants to do anyway. You also have those same proxies
caching it anyway.
As for running everything through a cgi process, then you have
the overhead of the cgi process to deal with. Then you also have to
build all the cgi programs you might have residing in this directory
to use your authentication scheme. By allowing based on IP address you
have none of this overhead and programming/debugging time to deal
with. All you need to do is manage sessions. If you have the time by
all means go the more secure way.
Myself, if all I'm protecting is a few files and a members
discussion area I would use, first of all, basic authentication. If
thats not working correctly, I'm not going to filter everything
through a cgi backend process. No need to waste resources just because
its not pretty.
If you really have something that has to be heavily protected
I bet theres a couple of Apache Modules written just for that purpose.
Better yet get a VPN.
MP
------------------------------
Date: Mon, 05 Jun 2000 18:23:00 -0700
From: Trevor Peirce <trev@hostyersite.com>
Subject: Sockets -- Packet at a time?
Message-Id: <393C5274.C110D442@hostyersite.com>
Hello,
Is there a way to have Perl receive a packet at a time? The server I
need to connect to interacts kinda as follows (>> is what server sends,
each line is one packet, << is what I send to the server)
<<l
>>l
>>contents
I need to be prepared to handle data in sets of packets -- if I get an
'l' that means a channel list is comming, and the next packet will be
just that. I don't know the length so I cannot predict how much to read
before the next response comes in.
Thanks,
Trevor Peirce
--
Trevor Peirce,
HostYerSite Affordable Hosting - http://www.hostyersite.com
Adgrafix Alliance Partner - http://digital.adgrafix.com
------------------------------
Date: Tue, 06 Jun 2000 01:48:42 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Still a little puzzled (Was Re: Globbing with ActivePerl)
Message-Id: <_LY_4.101802$hT2.417837@news1.rdc1.ct.home.com>
Swee Heng <sweeheng@usa.net> wrote:
>> Whenever I try this little program:
>> # start program scan.pl
>> while ( <> ) {
>> print "Scanning file $ARGV ...\n";
>> }
>> # end program scan.pl
> What is $ARGV doing there? @ARGV has nothing to do with $ARGV. And $ARGV has
> nothing to do with $ARGV[0]. But @ARGV is related to $ARGV[i] - the latter
> being the (i+1)-th element of the former. Got it?
Sure it does. $ARGV holds the name of the file out of @ARGV that you're
currently processing. I wouldn't want to print it for every line read, but
it is valid and it will work. That code's correct, and it'll print
Scanning file <somefile> ...
once for each line in each file in @ARGV, changing filenames when perl
switches files.
dan
------------------------------
Date: Mon, 05 Jun 2000 21:06:40 -0400
From: MC <mc@backwoods.org>
Subject: strict doesnt like array references
Message-Id: <393C4EA0.AA79656D@backwoods.org>
given the code below, which works perfectly w/o the use strict, but crashes with
the error:
Can't use string ("array") as an ARRAY ref while "strict refs" in use at test.pl
line 10.
when i add "use strict". in the actual script, i have two arrays which i need to
select between arbitrarily based on another variable. is there some way i can do
this and still keep strict? other than using an if/then/else structure?
MC
use strict;
my @array = qw( this is a test );
my $test = "array";
print @array;
print @{$test};
--
---------------------------------------------------------------------
My email address(s) are my private property. They are NOT to be used
or recorded for ANY reason without my explicit permission. Disregard
of this statement is in violation of federal privacy & copyright law.
---------------------------------------------------------------------
The new Decade/Century/Millennium doesnt start until the year 2001 !!
Lets make the year 2000, the last year of the Millennium, a good one!
--------------------------------------------+------------------------
|
<-- THIS SPACE FOR RENT --> | Question Reality
advertise~backwoods.org |
|
Time is nature's way of keeping | If at first you don't
everything from happening at once | succeed... REBOOT!
|
--------------------------------------------+------------------------
------------------------------
Date: Mon, 05 Jun 2000 18:16:50 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: strict doesnt like array references
Message-Id: <393C5102.8EC66280@My-Deja.com>
> when i add "use strict". in the actual script, i have two arrays which i need to
> select between arbitrarily based on another variable. is there some way i can do
> this and still keep strict? other than using an if/then/else structure?
>
use strict;
no strict 'refs' ;
or else perl thinks you are using symbolic referecnes.
------------------------------
Date: Mon, 05 Jun 2000 20:39:35 -0600
From: Mark Holt <madmardy@madmardy.com>
Subject: Re: strict doesnt like array references
Message-Id: <393C6467.B5B8DAB4@madmardy.com>
you are using symbolic references. And this is forbidden by 'use strict'. There is
usually a way to program without symbolic references, but if not, do as it says below
and wrap the offending code thus:
no strict 'refs';
--code--
use strict 'refs';
Makarand Kulkarni wrote:
> > when i add "use strict". in the actual script, i have two arrays which i need to
> > select between arbitrarily based on another variable. is there some way i can do
> > this and still keep strict? other than using an if/then/else structure?
> >
>
> use strict;
> no strict 'refs' ;
>
> or else perl thinks you are using symbolic referecnes.
------------------------------
Date: Tue, 06 Jun 2000 13:05:49 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Stupid Question: scripts won't recognize opening line
Message-Id: <393C6A8D.3D18@modulus.com.au>
Charles Petersen wrote:
>
> Ok, there is probably a very simple solution to this, but I can't seem
> to solve it.
>
> I'm running perl on Redhat 6..2. I have one script that works just
> fine, it's debugged and I start it by simply typing
>
> ./simulation.pl
>
> it then executes and works fine.
>
> I have another script which works fine when i type "perl test.pl" but
> doesn't work when i type
>
> ./test.pl
>
> the permissions are chmod 755 and the permissions are the same as the
> previous. the opening line is:
>
> #!/usr/bin/perl -w
>
> the error it gives me is:
>
> bash: ./index.pl: No such file or directory
>
> suggestions?
>
> Charles Petersen
More of a guess than a suggestion.
I *guess* that test.pl reqyires or uses "./index.pl", which, by the
syntax, needs to be present in the directory of test.pl.
In the absence of any code, we can only guess.
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3261
**************************************