[13034] in Perl-Users-Digest
Perl-Users Digest, Issue: 444 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 10 11:07:47 1999
Date: Tue, 10 Aug 1999 08:05:12 -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 Tue, 10 Aug 1999 Volume: 9 Number: 444
Today's topics:
A Guide: How to ask better questions (I R A Darth Aggie)
ANNOUNCE: Proc::Processtable 0.16 (Daniel J Urist)
Re: Announcement: "CRAP" (Tony Kennick)
Re: Announcement: "CRAP" (Greg Bacon)
Re: chop? Split? help? (Abigail)
Re: Custer's Last Code (I R A Darth Aggie)
Date::Manip SLOW <paulm@dirigo.com>
Re: Displaying form data before emailing... please help <Mark@Mark.Com>
Fastest way to search a txt file? srhadden@my-deja.com
glob() question <cantrela@agcs.com>
Re: glob() question (Mike Bristow)
Re: Help - Split Function Blowing My Mind Away!! (Anno Siegel)
HELP: Use of regular expression <dominique.cretel@cfwb.be>
Re: kill pid scripts (Mike Bristow)
Re: ldap hang <alex@kawo2.rwth-aachen.de>
Re: ldap hang (Michel Dalle)
Re: Need help with Perl expression and replace (Anno Siegel)
Re: New posters to comp.lang.perl.misc <sariq@texas.net>
Newbie: File I/O & Locking (Chris)
Re: Newbie: File I/O & Locking (Bart Lateur)
Re: Nicer Way (Mike Bristow)
Re: perl prog: Top site thingy.. <alex@kawo2.rwth-aachen.de>
Re: Perl/SSI hacking <mkirkpatrick@webbuilders.top.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Aug 1999 13:53:47 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: A Guide: How to ask better questions
Message-Id: <slrn7r0brg.3h2.fl_aggie@thepentagon.com>
Better questions lead to better answers. Please help those from whom
you seek help. Thanks...
James
Date: 09 Nov 1995 02:57:30 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: system() question
There are a lot of reasons, many of which get repeated over and
over again, many of which don't. Some of the reasons you hear a lot
are: Questions are incoherently phrased. Questions have the form `my
code doesn't work' and don't include the code. Questions include the
code, and it's 200 lines long, and comp.lang.perl is not a debugging
service. Nobody knows the answer to the question. The question is so
badly punctuated that nobody can bear to read it. Questions aer
written by a non-native speaker of English and the native speakers who
are trying to understand it can't. (That's a shame, but it does
happen. I often wish that these people would post in their native
languages. I'd love to see more discussion in languages other than
English. Some Dutch guy tried posting all his comp.lang.c articles in
Dutch a few years ago, and all the Americans flamed him. How
humiliating for me!)
Apart from these oft-mentioned reasons are many others that are
not so often discussed, because anyone who tries to bring them up gets
flamed. But it's the truth: I know the reason I don't answer more
questions is because so many of them questions are so damn stupid.
They're stupid in a lot of different ways, but they're still stupid.
I don't want to suggest that that's why your questions go unanswered.
I don't know what you're asking. No doubt the reason your questions
go unanswered is because they're so deep and interesting that nobody
really knows the answer.
The most common stupid question is the one from someone who has
some high-level problem that they need solved. They have an idea that
they'd like to do it in perl, and they don't really know perl. So
instead of learning perl, they post to comp.lang.perl.misc.
Now don't get me wrong. I don't have any problems answering the
questions of someone who's trying to learn perl. I love THOSE
qusetions. But these people don't seem to be asking useful questions
for that.
Today, for example, I saw a question from a guy who wants to get a
list of hostnames out of nslookup. `How do I do that?' he says. And
it's hard to know what to make of that. What does he mean? Does he
not know how to open a pipe? Is his `open' command failing? What's
going on here? I can't give a useful answer without understanding the
problem. Having your `open' fail is a problem. Wanting to list
hostnames is not a problem; it's a desire.
Here are some similar questions that would have made more sense to me:
1. ``I'm a lazy asshole and I can't be bothered to learn to
program myself, but I know if I post here you'll give me
something for free.''
(OK, fair enough. At least I can send him a rate card.)
2. ``I'm trying to use `open' to talk to nslookup, but...
...here's my code; what's wrong?''
(Good question.)
3. ``I know perl has a `system' command for running programs,
but I can't see how to get my commands into nslookup
once I have run it.''
(Good question.)
4. ``I'm trying to use `getprotobynumber' to talk to nslookup...''
(Good question.)
See, I'm not just biting people's heads off, here. #4 is a good
question, because it gives me something to work with. OK, he has a
very weird idea about interprocess communication, but that's
ignorance, and that's what we're here to correct. He doesn't know
about `open'; I can refer him to the manual.
Here's another example: Some guy wants to assemble a list of email
addresses . ``How do I do that?'' he wants to know. Well, duh. Get a
big pad of paper and read news for a couple days and write down all
the addresses you see. Problem solved. What's it doing in
comp.lang.perl?
Oh, you wanted to do it in perl. Well, I guess I'd open a socket
to the NNTP server and send it some XHDR commands for the `From'
lines. But that's not Perl; you could do that in any language. I
could do it in Bourne Shell for you if I'm allowed to use a little
external thingie to handle the socket parts for me. What's it doing
in comp.lang.perl?
Oh, you wanted us to write the program for you? Wait, let me send
you my rate card.
Someone posted yesterday asking how to get the data from a file
where the start and end of the data is marked by keywords. Same thing
going on here. ``Well, here's how you solve your problem: First you
go take an introductory class in programming and learn to write
programs in some language. Then you go to the bookstore and buy this
book by Wall and Schwartz, it's really good. Read the book carefully
and try out the examples. Then if you still have general questions
like `How do I do this' instead of `I thought that this code would do
X but instead it does Y' you hire a professional to write your program
for you. Or you could just skip right to step 3. Want my rate
card?''
The worst stupid questions are the ones that come from people who
have no business asking them. The most perfect example of this that I
could have imagined was in comp.unix.questions a couple of years ago.
Some guy came and asked how you could tell if a file is a hard link.
My jaw flapped open and it's stayed open since then. I couldn't have
been any more stumped if he'd asked why Bodhidharma came from the
West. What do you say to this guy? Do you tell him the truth, that
all files are hard links, that even symbolic links are hard links?
He's not going to understand you; you might as well keep your mouth
shut. Do you tell him the truth, that the answer won't do him any
good because he doesn't know what a hard link is, so why did he bother
asking in the first place? No, that'll just make him mad. I followed
that message for the next couple weeks, and nobody said anything.
What could you say? The guy had no business asking the question and
no use for the answer. Maybe the right answer would have been to cut
off his finger or something. I dunno.
Some questions get ignored because they're boring. Someone asked
today how to compare two variables (I assumme he means the contents of
those variables) to see if they're exactly the same. You've gotta be
in an awfully good mood to take the time to answer that. Maybe
someone will. Maybe I will.
If I answer that one today, maybe he'll be back tomorrow asking
how to check to see if two variables contain different values. Maybe
I won't. What I find incredible is that if you tell these people to
go read the manual and come back in two weeks, you sometimes get
jumped on for not being helpful to beginners. Bah. If everyone told
these people to go read the manual, they'd eventually figure out that
that's what you have to do ,and then I wouldn't have to spend so much
of my life dealing with incompetent programmers.
Some questions are logically nonsensical because the querent
thinks they know more than they do. A lot of these have the form
``How do I use X to accomplish Y?'' There's nothing wrong with this,
except that sometimes X is a chocolate-covered banana and Y is the
integration of European currency systems. I always get stuck on
these, probably because I can't get rid of the idea that the person
really has a good reason for wanting to use X. I know a half-dozen
easy simple ways to accomplish Y, but I can't imagine what X has to do
with it. This is a problem for me in my day job, too. Clients are
always saying to me ``We want to use product X to do multimedia
development on the world-wide web,'' and all I can think is ``Well,
gee, what would you want to go and do that for?'' Sometimes it turns
out that they want to do it because they want to impress the
manufacturers of X, and I don't work on those jobs.
The flip side of this is a questions like ``I want to accomplish
X, but I don't want to use Y. What can I use instead?'' Which,
again, is sometimes reasonable, and then sometimes X is closing a
filehandle and Y is the `close' function.
The questions I like the best are the ones that go like this:
``I want to accomplish X.
I thought that the following code fragment would do it:
...
But instead it does Y.
Why is that?''
This one is also pretty good:
``I want to accomplish X.
I thought I might be able to use facility Y.
But Y doesn't seem like it's quite right,
because of Z.
What should I use instead of Y, or how can I overcome Z?''
When I ignore these, it's usually because I don't know the answer.
There were an awful lot of them today. It makes me very happy.
There you go; a 160-line dissertation on why questions go unanswered.
Now don't let me hear you saying nobody ever answers your questions.
------------------------------
Date: 10 Aug 1999 13:22:01 GMT
From: durist@world.std.com (Daniel J Urist)
Subject: ANNOUNCE: Proc::Processtable 0.16
Message-Id: <7op91p$8l1$1@play.inetarena.com>
Proc::ProcessTable is a perl module to provide a consistent
object-oriented interface to the process table on different
Unix and Unix-like operating systems. This version contains new
support for DEC-OSF provided by Bernhard Schmalhofer, and BSDI
provided by Sean Eskins. In addition there is support for linux,
solaris, AIX, HPUX, freebsd and IRIX.
--
Dan Urist
durist@world.std.com
http://www.world.std.com/~durist
------------------------------
Date: Tue, 10 Aug 1999 14:00:58 GMT
From: tony@showroom.org.uk (Tony Kennick)
Subject: Re: Announcement: "CRAP"
Message-Id: <37b0303b.6458228@missy.shef.ac.uk>
"Alan J. Flavell" <flavell@mail.cern.ch> imparted the following:
:->On 3 Aug 1999, Gisle Aas wrote:
:->
:->> > Ahem! <URL:http://www.pobox.com/%7Ejaphy/perl/crap/>
:->>
:->> RFC 2396 made ~ unreserved. No need to escape it.
:->
:->Right. It's still legal to escape it, though, and there's a number of
:->arguments in favour of doing so. I've been too lazy to do so on web
:->pages since even before rfc2396 legitimated it (and a number of
:->more-dubious practices), but outside of web pages it might still be wise
:->to consider escaping it. IMHO, of course.
:->
:->OTOH it might be wise to avoid using it in URLs at all. Its
:->introduction was clearly by analogy with unix practice, but it does
:->cause a degree of user confusion, and I see that many WSPs are now
:->supporting different conventions for representing their users'
:->private web pages.
The other problem with ~ is that some firewallls block it since, in
their mind a URL with it in has to be a set of personal pages rather
than anything that could possibly be work related.
--
From Tony Kennick aka Gonzo The Great
http://missy.shef.ac.uk/users/old-firm/
Gonzo: Slang for "the last man standing
at a drinking marathon"
------------------------------
Date: 10 Aug 1999 15:04:19 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Announcement: "CRAP"
Message-Id: <7opf1j$1tp$2@info2.uah.edu>
In article <37b0303b.6458228@missy.shef.ac.uk>,
tony@showroom.org.uk (Tony Kennick) writes:
: The other problem with ~ is that some firewallls block it since, in
: their mind a URL with it in has to be a set of personal pages rather
: than anything that could possibly be work related.
Ye gods, those must be fast networks! :-)
Greg
--
Conservatives are not necessarily stupid, but most stupid people are
conservatives.
-- John Stuart Mill
------------------------------
Date: 10 Aug 1999 09:38:00 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: chop? Split? help?
Message-Id: <slrn7r0e9p.b9b.abigail@alexandra.delanet.com>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMCLXX September
MCMXCIII in <URL:news:7op5ln$n3k$1@lublin.zrz.tu-berlin.de>:
,,
,, while ( $_ = readdir( BUSDIR) ) {
,, next if m/^\.$/; # skip .
,, next if m/^\.\.$/; # and ..
Tom P. recently pointed out that this matches files named ".\n" and "..\n",
which are certainly allowed in most Unix filesystems. That, and given that
eq usually is a lot faster than m//, why not:
next if $_ eq '.';
next if $_ eq '..';
Or, combined:
next if $_ eq '.' or $_ eq '..';
Explicit matching is also clearer than the regex.
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 10 Aug 1999 13:31:38 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Custer's Last Code
Message-Id: <slrn7r0ahv.3h2.fl_aggie@thepentagon.com>
On Mon, 09 Aug 1999 17:41:01 -0700, Frank Krul <fkrul@acc.com>, in
<37AF751D.7A1A5B46@acc.com> wrote:
+ Insecure $ENV{PATH} while running setuid at /dev/fd/3 line 120.
This is a feature, not a flaw.
+ So I thought I could circumvent the simple system calls that generated
+ these errors:
So, you felt the need to circumvent perl's security features? Go read
perlsec -- 'man perlsec'.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Tue, 10 Aug 1999 14:12:02 GMT
From: Stone Cold <paulm@dirigo.com>
Subject: Date::Manip SLOW
Message-Id: <7opbv7$br3$1@nnrp1.deja.com>
I'm using the Date::manip module to print a range of dates (e.g. Jan-
99, Feb-99, Mar-99, etc). I'm finding, though, that this modules
really slowed down my CGI program. Before I started using the module,
my output would come up in browser pretty fast.
So, does anyone know how to speed up the date::manip module?
--
Paul R. Mesker
System Engineer
Dirigo Inc.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 10 Aug 1999 14:33:17 +0100
From: Mark <Mark@Mark.Com>
Subject: Re: Displaying form data before emailing... please help...
Message-Id: <37B02A1D.BB566142@Mark.Com>
Pelican Brief wrote:
> Hello everyone,
>
> I'm stuck with a cgi script.
>
> I'd like to display the data from a form before it is
> emailed so it can be checked/verified. I can get the two
> components of this idea to work (the displaying and the
> mailing) but am stuck as to how to put the two together.
>
> I'm guessing I need to know how to wait for an OK from the
> visitor before the MAIL starts - but is this all part of
> the one script?
>
> See... I am confused...
>
> Any help would be appreciated.
>
> Thanks in advance.
>
> Iain
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
> The fastest and easiest way to search and participate in Usenet - Free!
Read
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
very carefully
Particularly the simple examples. Use this with perl. It is f****ing brilliant.
Well, it's at least a lot better than not using it.
Don't even think about writing CGI scripts without it.
Essentially, you want the same script in different modes:
unless ($q->param('button')) # no params => print form with submit = 'button'
{
$q->start_form;
...
....
}
elsif ($q->param('button') eq 'Check Email'))
{
# print out email that would be sent, create form with button == 'Submit
Email'
# pass email parameters as 'hidden' fields $q->hidden.
}
elsif ($q->param('button') eq 'Submit Email'))
{
# There is a Mail module. Try perldoc Mail or CPAN
open FRED "|sendmail" or die "blah"; # blah, blah
print FRED,..........
close FRED;
}
------------------------------
Date: Tue, 10 Aug 1999 13:33:38 GMT
From: srhadden@my-deja.com
Subject: Fastest way to search a txt file?
Message-Id: <7op9ni$a0s$1@nnrp1.deja.com>
Hi, I hope I don't get roasted for asking this...
I was wondering what would be a very efficient (fast) way to examine a
text file line by line to search for keywords, such as "error", or
"warning".
The code I'm working on now takes the file and redefines $/, which
allows a chunk of the file to be extracted, and then has perl search the
entire chunk for one of the keywords. If a keyword is detected in the
chunk, then the chunk is split into lines and each line is examined for
the information and certain count variables are updated depending on how
many lines contain a keyword.
I suppose some issues are that maybe the file doesn't contain any
keywords at all. Would it be too slow to have perl search the entire
file for a keyword? Is it quicker to search the file chunk by chunk
rather than just search the entire file once for a keyword?
Anyway, if you understand what I'm asking I'd appreciate any input.
Thanks.
SRHADDEN
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 10 Aug 1999 06:01:25 -0700
From: Andy Cantrell <cantrela@agcs.com>
Subject: glob() question
Message-Id: <37B022A5.C5D66195@agcs.com>
Looked though the FAQ and didn't come across this:
The following code snippet will pass through the
first loop but not the second. In advance I know
that no file that looks like *zork* exists under
the /tmp directory. Is this an expected result?
foreach $file_name (glob("/tmp/zork")) {
print "loop 1 >>$file_name\n";
};
foreach $file_name (glob("/tmp/zork*")) {
print "loop 2 >>$file_name\n";
};
I used to use opendir() but have gotten lazy lately.
I'm getting around this by using the -f file test
operator (i.e. next if ! -f $file_name)
--
Andy Cantrell - cantrela@agcs.com
AG Communication Systems
Office (AZ) (623) 582-7495 (Voice mail)
Office (WI) (414) 249-0215
Modem (WI) (414) 249-0239
------------------------------
Date: Tue, 10 Aug 1999 14:15:31 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: glob() question
Message-Id: <slrn7r0d03.7jm.mike@lindt.fat.dotat.at>
On Tue, 10 Aug 1999 06:01:25 -0700, Andy Cantrell <cantrela@agcs.com> wrote:
> The following code snippet will pass through the first loop but
> not the second. In advance I know that no file that looks like
> *zork* exists under the /tmp directory. Is this an expected
> result?
Yes. It seems to behave as I expect; what were you expecting?
mike@work:~$ touch /tmp/zork
mike@work:~$ touch /tmp/zorkwibble
mike@work:~$ perl -w
foreach $file_name (glob("/tmp/zork")) {
print "loop 1 >>$file_name\n";
};
foreach $file_name (glob("/tmp/zork*")) {
print "loop 2 >>$file_name\n";
};
^D
loop 1 >>/tmp/zork
loop 2 >>/tmp/zork
loop 2 >>/tmp/zorkwibble
mike@work:~$ rm /tmp/zork*
mike@work:~$ perl -w
foreach $file_name (glob("/tmp/zork")) {
print "loop 1 >>$file_name\n";
};
foreach $file_name (glob("/tmp/zork*")) {
print "loop 2 >>$file_name\n";
};
^D
loop 1 >>/tmp/zork
mike@work:~$ perl -V | grep ver
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
osname=solaris, osvers=2.6, archname=sun4-solaris
cc='gcc', optimize='-O', gccversion=2.8.1
mike@work:~$
Now, you may get confused by the ``/tmp/zork'' return from my second run;
see below.
> foreach $file_name (glob("/tmp/zork")) {
> print "loop 1 >>$file_name\n";
> };
I'll point out that this is a totally useless glob; it can only match
/tmp/zork. In, fact, it'll always return /tmp/zork as you'll find out
if you look at the FM for `glob' (perldoc -f glob will point you at
the I/O Operators section in perlop). Basically
@list = glob(something)
is equivilant to
open FOO, "echo something | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
@list = <FOO>
--
Mike Bristow, Geek-At-Large. GK/RT0038
one tequila - two tequila - three tequila - FLOOR !!!
------------------------------
Date: 10 Aug 1999 13:35:02 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help - Split Function Blowing My Mind Away!!
Message-Id: <7op9q6$n84$1@lublin.zrz.tu-berlin.de>
Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>Write that line thus:
>
> @record = split(/\|/, $_[0]);
>
>And all will be well. (This is on my Top Ten list of Perl surprises for
>beginners. The vertical bar is a popular field separator!)
A case of "Ceci n'est pas une pipe"?
Anno
------------------------------
Date: Tue, 10 Aug 1999 16:43:28 +0200
From: Dominique Crétel <dominique.cretel@cfwb.be>
Subject: HELP: Use of regular expression
Message-Id: <37B03A90.657D@cfwb.be>
Hi,
I have a problem on determining a RE:
I use UNPACK function with the format "A11A12A256A12A41A31".
I would like to sum every length field "A" with a RE (for example, the
result of this format should be 363).
I have tried this but it isn't very powerfull!
------code-------------------------------------------
#!/usr/bin/perl
$format = "A11A12A256A12A41A31";
@t = split(/A/, $format); $len = 0;
for $x (@t) {$len += $x;}
print "somme=$len\n";
------code-------------------------------------------
How can I manage this?
Thanks,
Dominique Crétel
------------------------------
Date: Tue, 10 Aug 1999 14:18:33 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: kill pid scripts
Message-Id: <slrn7r0d5p.7jm.mike@lindt.fat.dotat.at>
On 9 Aug 1999 15:46:04 GMT, Jerome O'Neil <jeromeo@atrieva.com> wrote:
>In article <slrn7qs86i.9fk.abigail@alexandra.delanet.com>,
> abigail@delanet.com (Abigail) writes:
>> Dutch McElvy (dutch@mindspring.com) wrote on MMCLXVIII September MCMXCIII
>> in <URL:news:7ol1k0$is0$1@nntp6.atl.mindspring.net>:
>> ``
>> `` kill -9 `ps -ef | grep foo | awk -e '{print $2}'`
>>
>> That doesn't compile.
>
>ksh finds it quite agreeable.
Remind me, what was the name of this newsgroup again?
Does it have a ``ksh'' in the title? No?
Perhaps it was not unreasonable to assume that the code posted
was perl, given that it /almost/ compiles?
>> You need a , after the -9. Are your sure you want
>> to kill process groups? With a SIGKILL? Shouldn't you first try a more
>> friendly SIGTERM?
Oh, look! Instructions on how to make the code with
perl!
--
Mike Bristow, Geek-At-Large. GK/RT0038
one tequila - two tequila - three tequila - FLOOR !!!
------------------------------
Date: Tue, 10 Aug 1999 16:16:26 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Dean Gayhart <dgayhart@walcoff.com>
Subject: Re: ldap hang
Message-Id: <37B0343A.2877E1BA@kawo2.rwth-aachen.de>
Hi Dean,
Dean Gayhart wrote:
> hi. anyone know why an ldap script may be hanging even after it does
> its task?
> it completes its task from the command line but not when called from a
> web page.
> any ideas?
does your script print Content-type: blah blah \n\n at the beginning?
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Tue, 10 Aug 1999 14:52:28 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: ldap hang
Message-Id: <7opeh0$m3g$2@news.mch.sbs.de>
In article <37B01F33.8C650E97@walcoff.com>, Dean Gayhart <dgayhart@walcoff.com> wrote:
>hi. anyone know why an ldap script may be hanging even after it does
>its task?
>it completes its task from the command line but not when called from a
>web page.
>any ideas?
>
Perl Faq 9 may have a few clues. For instance, the following two topics :
--------------------------
My CGI script runs from the command line but not the
browser. (500 Server Error)
If you can demonstrate that you've read the following FAQs and that your
problem isn't something simple that can be easily answered, you'll probably
receive a courteous and useful reply to your question if you post it on
comp.infosystems.www.authoring.cgi (if it's something to do with HTTP,
HTML, or the CGI protocols). Questions that appear to be Perl questions but
are really CGI ones that are posted to comp.lang.perl.misc may not be so well
received.
The useful FAQs and related documents are:
CGI FAQ
http://www.webthing.com/tutorials/cgifaq.html
Web FAQ
http://www.boutell.com/faq/
WWW Security FAQ
http://www.w3.org/Security/Faq/
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/TR/REC-html40/
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://www.w3.org/CGI/
CGI Security FAQ
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
--------------------------
How can I get better error messages from a CGI program?
Use the CGI::Carp module. It replaces warn and die, plus the normal Carp
modules carp, croak, and confess functions with more verbose and safer
versions. It still sends them to the normal server error log.
use CGI::Carp;
warn "This is a complaint";
die "But this one is serious";
The following use of CGI::Carp also redirects errors to a file of your choice,
placed in a BEGIN block to catch compile-time warnings as well:
BEGIN {
use CGI::Carp qw(carpout);
open(LOG, ">>/var/local/cgi-logs/mycgi-log")
or die "Unable to append to mycgi-log: $!\n";
carpout(*LOG);
}
You can even arrange for fatal errors to go back to the client browser, which
is nice for your own debugging, but might confuse the end user.
use CGI::Carp qw(fatalsToBrowser);
die "Bad error here";
Even if the error happens before you get the HTTP header out, the module
will try to take care of this to avoid the dreaded server 500 errors. Normal
warnings still go out to the server error log (or wherever you've sent them
with carpout) with the application name and date stamp prepended.
--------------------------
Michel.
------------------------------
Date: 10 Aug 1999 13:29:52 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need help with Perl expression and replace
Message-Id: <7op9gg$n6l$1@lublin.zrz.tu-berlin.de>
Warren Bell <resource@ERASEjps.net> wrote in comp.lang.perl.misc:
>Can I do somthing like this:
>
>If quotes are inside greater than and less than signs < >, strip them,
>otherwize leave them alone?
You'll have to specify some more, in particular, how nested <> should
be treated. Example:
...alpha<beta<gamma>"delta"...
Would the quotes around delta be inside <> or outside?
Anno
------------------------------
Date: Tue, 10 Aug 1999 09:22:58 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: New posters to comp.lang.perl.misc
Message-Id: <37B035C2.33EAFED4@texas.net>
Abigail wrote:
>
> Greg Bacon (gbacon@cs.uah.edu) wrote on MMCLXIX September MCMXCIII in
> <URL:news:7omnhj$ebe$2@info2.uah.edu>:
> ##
> ## Top 10 Posters by Number of Posts
> ## =================================
> ##
> ## (kb) (kb) (kb) (kb)
> ## Posts Volume ( hdr/ body/ orig) Address
> ## ----- -------------------------- -------
> ##
> ## 42 66.9 ( 33.8/ 31.5/ 19.5) elephant@squirrelgroup.com (elephant)
> ## 14 28.8 ( 14.7/ 14.1/ 3.8) "Ben Quick" <newsgroup@bigwig.net>
> ## 8 14.1 ( 6.7/ 7.3/ 1.9) stirling@banet.net
> ## 8 21.0 ( 6.9/ 14.2/ 7.8) "James A Culp III" <admin@futuristic.net>
> ## 8 19.8 ( 6.8/ 13.0/ 8.9) mck@iag.net (Matt)
> ## 7 9.7 ( 5.1/ 4.5/ 4.5) "Scott" <codeman@gol.com>
> ## 7 10.1 ( 4.1/ 5.9/ 4.4) "Perl King" <perlking@hotmail.com>
> ## 6 12.2 ( 5.5/ 6.7/ 4.0) Andrew Fry <andrewf@beausys.freeserve.co.u
> ## 6 14.7 ( 4.6/ 10.1/ 3.5) "99% Energy" <Spam@IsBadForTheInternet.com
> ## 6 7.4 ( 4.5/ 2.9/ 1.8) Eric Turner <erict@cc.wwu.edu>
>
> 30% of them managed to end up in my killfile in the same week
> they started posting here.
>
> Abigail
20% were in *my* killfile *before* they posted here.
- Tom
------------------------------
Date: Mon, 09 Aug 1999 14:04:19 GMT
From: chrisl@hamptons.com (Chris)
Subject: Newbie: File I/O & Locking
Message-Id: <37aedf53.8159617@news.swbell.net>
Hey all,
I have some simple CGI scripts I have to write. They're going to be
reading and writing a common file, so I need some synchronization. Is
there some package that offers file locking? If not, do I just do
something like
while (!open(OUT, "> common.txt"))
{
# Loop until the file is free
}
without getting laughed at?
Thanks a lot,
Chris
P.S. Happy 30th to me!!!
------------------------------
Date: Tue, 10 Aug 1999 14:41:31 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Newbie: File I/O & Locking
Message-Id: <37b23690.12877660@news.skynet.be>
Chris wrote:
>I have some simple CGI scripts I have to write. They're going to be
>reading and writing a common file, so I need some synchronization. Is
>there some package that offers file locking? If not, do I just do
>something like
>
> while (!open(OUT, "> common.txt"))
> {
> # Loop until the file is free
> }
>
>without getting laughed at?
It depends on the OS. If on Windows, your idea might not be so bad,
although it may hang permanently. At least, check WHY the open failed
(see $!).
On Unix and related systems, the open WILL succeed even if the file is
"locked". There, locking files is a convention. So don't use ">",
because this will erase the file before locking it! "+<" plus
seek()/truncate() is better. See "perldoc -f flock" and "perldoc -q
lock" for details/examples.
flock OUT, 2; # LOCK_EX
This line will wait until the file is free, and lock it exclusively.
Just close the file to unlock it. Unlocking without closing is
considered unsafe.
BTW if you're going to rewrite the whole file anyway, why is this a
common file?
The lot:
open(OUT,"+< common.txt");
flock OUT, 2;
# seek OUT, 0, 0; # Don't need this if you haven't read from it
truncate OUT, 0;
print OUT "Hello there!\n";
close OUT;
Bart.
------------------------------
Date: Tue, 10 Aug 1999 14:22:33 GMT
From: mike@fat.dotat.at (Mike Bristow)
Subject: Re: Nicer Way
Message-Id: <slrn7r0dd9.7jm.mike@lindt.fat.dotat.at>
On Mon, 9 Aug 1999 09:57:27 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>In article <rqtrki89kur47@corp.supernews.com> on Mon, 9 Aug 1999
>10:09:12 -0500, Scott Beck <admin@gatewaysolutions.net> says...
>> Mabe there is somthing wrong with the way Outlook Exp. is reading the Mime
>> Type.
>> What program are you using and where can I get a copy. I've been looking for
>> somthing to replace Outlook!
>
>Anything is better than X-Newsreader: Microsoft Outlook Express
>5.00.2314.1300.
>
>My choice is Gravity, at http://www.microplanet.com/, which costs about
>$30 and is well worth it in terms of functionality and your time saved.
If I had to use windows, I'd probably use turnpike
for news and mail (<URL:http://www.turnpike.com>).
But then, the company I work for owns the company that
owns the company that produces it.
Now, where was that perl question, I had it a minute ago,
honestly, forget me own head next.
--
Mike Bristow, Geek-At-Large. GK/RT0038
one tequila - two tequila - three tequila - FLOOR !!!
------------------------------
Date: Tue, 10 Aug 1999 16:36:39 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: arpith@hotmail.com
Subject: Re: perl prog: Top site thingy..
Message-Id: <37B038F7.B535ADE1@kawo2.rwth-aachen.de>
Hi Arpith,
arpith@hotmail.com wrote:
> How do I call another perl program from a perl
> program itself ?
see
perldoc -tf system
perldoc -tf exec
perldoc -tf open
perldoc perlop
> Supposing halfway through the saving, the user Presses the "Stop" button
> on the browser, will the CGI script STOP execution midway ? or will it
My guess is: if the CGI-script tries reading from STDIN or writing
to STDOUT after that, then it will die because it receives SIGPIPE.
> continue till the end ? If it does stop, then the data file will get
> corrupted right ?
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: 10 Aug 1999 09:07:06 -0500
From: "Michael D. Kirkpatrick" <mkirkpatrick@webbuilders.top.net>
Subject: Re: Perl/SSI hacking
Message-Id: <elWr3.28447$k8.1203623@newscene.newscene.com>
Try this:
<IMG SRC="/cgi-bin/test.pl?VAR=IMAGE_PROTECTION_CODE&VALUE=43@3!ERT">
Have your perl code handle a get request. With that, you can pass anything
you want to the script.
You can put this in the beginning of your perl script:
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
$querystring=$ENV{'QUERY_STRING'};
@pairs = split(/&/, $querystring);
foreach $pair (@pairs){
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$query{$name} = $value;
}
}
if ($query{'VAR'} eq "IMAGE_PROTECTION_CODE"){&run_my_routine;}
sub run_my_routine{
$my_var = $query{'VALUE'};
## do what ever.....
}
Remember, in Perl, it is very case sensitive for both variables and their
values....
Hope this helps...
<mujali@my-deja.com> wrote in message news:7oa5v6$tts$1@nnrp1.deja.com...
> Hello all,
>
> Anyone out there willing to take a shot at this? I would really
> appreciate any hints. Here in an index.shtml (SSI-enabled) file:
>
> <HTML>
> <HEAD><TITLE></TITLE></HEAD>
> <BODY>
> <!--#SET VAR="IMAGE_PROTECTION_CODE" VALUE="43@3!ERT" -->
> <IMG SRC="/cgi-bin/test.pl">
> </BODY>
> </HTML>
>
> Here is test.pl:
>
> #!/usr/local/bin/perl
> print "Content-type: image/gif\n\n";
> # ---- Debug code ----
> open (TEMP, ">temp.txt");
> while (($key, $val) = each %ENV) {
> print TEMP "$key = $val<BR>\n";
> }
> close TEMP;
> # --------------------
> if ($ENV{'IMAGE_PROTECTION_CODE'} eq "43\@3!ERT") {
> open (IMAGE, "can't_get_me.gif") or die "$!";
> }
> else {
> open (IMAGE, "dummy.gif") or die "$!";
> }
> print <IMAGE>;
> close IMAGE;
>
> Problem is that the Perl script can't access the variable set by the SSI
> SET command in the index.shtml file becuase it has a different
> environment space (at least that's my thinking). If I had called the
> script using an SSI INCLUDE or EXEC command, it would have no problem
> seeing $ENV{'IMAGE_PROTECTION_CODE'}. Basically, is there any hack I can
> employ to get this variable from mod_include through the Perl script? (I
> hope that makes sense.) Or, is there a better way to do this?
>
> The purpose of this setup is of course to implement rudimentary image
> "protection". I am just doing this as an exercise. I understand someone
> could still get the image from their cache, etc. Thanks for any help.
>
> - Mujtaba Ali
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 444
*************************************