[9120] in Perl-Users-Digest
Perl-Users Digest, Issue: 2738 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 27 17:07:35 1998
Date: Wed, 27 May 98 14:00:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 27 May 1998 Volume: 8 Number: 2738
Today's topics:
500 Internal Server Error (newbie) dirt@xworld.com
backgrounding a daemon program <twells@netscape.com>
Backquote problem? <twhite@detailsinc.com>
Re: Backquote problem? (Craig Berry)
Re: Call another perl script <JKRY3025@comenius.ms.mff.cuni.cz>
Re: Call another perl script <tchrist@mox.perl.com>
Re: Clearly define "free software" (Chris Nandor)
Email address checker - comments welcome (Mark666769)
Re: Email address checker - comments welcome (brian d foy)
Re: file size with perl and win NT <JKRY3025@comenius.ms.mff.cuni.cz>
Re: GNU attacks on the open software community <evan@garrett.hpl.hp.com>
Re: GNU attacks on the open software community (Jonathan Stott)
Re: HELP! - Perl Query String Encoding <JKRY3025@comenius.ms.mff.cuni.cz>
Re: How can I get the system memory size of my system(L <p-fein@uchicago.edu>
Re: How to create nonblocking socket in Perl ? <jc@ral1.zko.dec.com>
Re: Invoking the Perl interpreter from DOS shell <JKRY3025@comenius.ms.mff.cuni.cz>
Re: Job Postings (brian d foy)
Re: list context: || vs or (Ilya Zakharevich)
Re: Modules in Perl (brian d foy)
Re: Modules in Perl <JKRY3025@comenius.ms.mff.cuni.cz>
Re: Need a "word-count" <tchrist@mox.perl.com>
Re: Need a "word-count" <lr@hpl.hp.com>
Re: new to OO Perl <jc@ral1.zko.dec.com>
Re: Okay, NOW I'm confused (redirect) <lr@hpl.hp.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 May 1998 20:53:14 GMT
From: dirt@xworld.com
Subject: 500 Internal Server Error (newbie)
Message-Id: <dirt-2705981651240001@xcom2.dialup.access.net>
So I'm learning PERL as I go, and I'm having some problems. I was hoping
there might be some good advice out there.
We're translating a site <http://www.esrb.com> into Spanish
<http://www.esrb.com/sesrb/>. And I can't get the search cgi's to work any
more.
The files and directory structures are identical to the French site
<http://www.esrb.com/fesrb/> (except, of course, for the language).
The syntax checks "OK" in MacPerl but debugger says, "Stack dump during
die enabled outside of evals." Whatever that means.
The files were saved as UNIX in BBEdit after alterations.
They were uploaded to the server as binary.
And the permisions have been set to executable on the server.
Yet, whenever I try to do a simple busqueda (search), I get "500 Internal
Server Error." Even though the identical (as far as I can tell) French
site works fine.
Does any of this sound familiar? Any suggestions would be great.
thanks,
oliver
--
Bookmark Dirtbag News at http://www.xworld.com/dirt/ for a daily roundup of entertainment news, gossip, and other pop culture minutiae.
------------------------------
Date: Wed, 27 May 1998 12:49:21 -0700
From: Tom Wells <twells@netscape.com>
Subject: backgrounding a daemon program
Message-Id: <356C6E41.6400@netscape.com>
I have a script that I would like to start a daemon
program that doesn't return, all the while returning
to the script. I open a socket to the system, supply
data to the server script. The server then needs to
restart 2 system daemons (in.rarpd and boot.paramd),
then return control to the server. Finally, the client
exits, and the socket is closed.
I've tried system, backticks, and open filehandles, and they all just
hang waiting for the processes that aren't supposed to die.
I then created a subroutine that forks a child, execs
the programs I want to run, and then exits. Seems to
work, but the socket still won't close correctly like
it does when I don't start the 2 programs. To verify
this, I put a print statement after the exec, and
after the calling of my subroutine. The print statement
after the exec never gets executed (like it should),
while the one after my subroutine does (like it should).
It's just that the stinking socket won't close until
the 2 exec'ed programs are killed.
any help.
Thanks.
Tom
------------------------------
Date: Wed, 27 May 1998 12:51:35 -0700
From: Tom White <twhite@detailsinc.com>
Subject: Backquote problem?
Message-Id: <356C6EC7.284DD0B3@detailsinc.com>
I'm having problems copying a file with perl.
system: HPUX10.20 perl, version 5.004_01
$ perl -e '`cp /usr/bin/ls .` || die "$!"'
No such file or directory at -e line 1.
Actually, the file is copied correctly. I just don't like the error I'm
getting.
Any ideas?
thanks
------------------------------
Date: 27 May 1998 20:47:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Backquote problem?
Message-Id: <6khu5f$kql$1@marina.cinenet.net>
Tom White (twhite@detailsinc.com) wrote:
: I'm having problems copying a file with perl.
:
: $ perl -e '`cp /usr/bin/ls .` || die "$!"'
: No such file or directory at -e line 1.
No need to doublequote $! in the above.
: Actually, the file is copied correctly. I just don't like the error I'm
: getting.
: Any ideas?
Yep, check the doc on ``. You'll find it returns the stdout from running
the command, not the error status. Since cp is normally silent, its lack
of output creates an empty string (in the scalar context imposed by ||).
Interpreted as a boolean value, an empty string is false, so the die() is
*always* executed. Since no error occurred, it reports whatever was lying
around in that variable.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Wed, 27 May 1998 20:59:56 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
To: Richard Amdi Madsen <ram@post4.tele.dk>
Subject: Re: Call another perl script
Message-Id: <356CE13C.3FF5@comenius.ms.mff.cuni.cz>
Richard Amdi Madsen wrote:
>
> Hi,
>
> I try to have one perl program call another, an redirect the output to
> the browser. The secound program works, because I can call it directly,
> but the first one gives "Document contains no data" in Netscape?
>
> Thanks for your help,
>
> Richard
>
> 1. program:
>
> #!/bin/perl
>
> print "Content-Type: text/html\n\n";
>
> open FH, "my_perl_prog.cgi |" || die "Error $! on open of pipe\n";
> while(<FH>) {
> print "$_";
> }
>
> 2. program: my_perl_prog
>
> #!/bin/perl
>
> print "Content-Type: text/html\n\n";
>
> print "output from my_perl_prog";
May I try a few wild guesses?
1.
You are running the CGIs on WinNT/95 ?
MSWin systems do not work well with IO redirection.
Namely they are not able to redirect the output
of scripts (anything else than .exe, .com and .bat(works in WinNT
only)).
Try to relace the
open FH, "my_perl_prog.cgi |" || die "Error $! on open of pipe\n";
by
open FH, "perl my_perl_prog.cgi |" || die "Error $! on open of pipe\n";
You may also be forced to do some tweaking of the webserver, the FAQs
and docs
should help you.
2.
Are you sure the CGI gets called?
Make it touch/create a file so you may say if it ran
even if you do not get the output.
open TOUCH, ">my_perl_prog.touch" and print TOUCH "Yup!" and close
TOUCH;
The posible causes are :
the current working directory is not what you expect.
the PATH ($ENV{PATH}) doesn't contain '.'
permissions
Try to use the full path.
HTH, Jenda
------------------------------
Date: 27 May 1998 19:15:15 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Call another perl script
Message-Id: <6khoo3$9he$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz> writes:
: open FH, "my_perl_prog.cgi |" || die "Error $! on open of pipe\n";
:by
: open FH, "perl my_perl_prog.cgi |" || die "Error $! on open of pipe\n";
You have precedence wrong.
You have open pipe retvals wrong.
You have the CGI protocol in an open statement!?
--tom
--
MS-DOS is CP/M on steroids, bigger bulkier and not much better.
Windows is MS-DOS with a bad copy of a Macintosh GUI.
NT is a Windows riddled with VMS.
------------------------------
Date: Wed, 27 May 1998 20:39:54 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Clearly define "free software"
Message-Id: <pudge-2705981634190001@dynamic265.ply.adelphia.net>
In article <slrn6mokdp.6tn.mdw@catbert.ebi.ac.uk>, mdw@ebi.ac.uk wrote:
# Essentially, consumer-grade software must sacrifice any form of
# usefulness to an experienced user just so that people with low
# intelligence and short attention spans can get poor quality output
# without having to waste time finding out how to do the job properly.
#
# Have I been venomous enough? I'm not sure I have.
Oh, hold on to yourself. Just because a lot of consumer-grade software is
like that, it certainly makes for no requirement. I use a Mac as my
primary computer, and I use lots of "consumer-grade" software, and I
actively search out and find the quality stuff in the group, stuff that is
reliable, usable, helpful, and -- very importantly -- automatable.
There are plenty of people who are most likely brighter than you who in
all liklihood make better software than you ever could, and make it for
the PC consumer, and it is good stuff.
Yes, most of it is crap. So? Most music is crap, most movies are crap,
most books are crap, most free software is crap (whatever your definition
of free), and most pay software is crap. Get used to it.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 27 May 1998 19:19:09 GMT
From: mark666769@aol.com (Mark666769)
Subject: Email address checker - comments welcome
Message-Id: <1998052719190900.PAA12131@ladder01.news.aol.com>
Hi all,
Submitted for your approval: yet another Email address
checker from the twilight zone. Any and all
comments and improvements would be most welcome.
-----------------------------------------------------
#!/usr/local/bin/perl
$send_to = "xyz\@bbc.com, <hghg\@rrr.com>, (john smith)
<john-smith\@aol.com>, h\$#%#\$%yhyfff.com";
for (split(/,\s*/, $send_to)) {
print "Checking: |$_|\n";
if (!&check_email($_)) {
print "Invalid Email address: $_\n";
}
}
#
# Check the Email address for basic syntax.
# Returns 1 if valid; 0 if invalid
# Based on an Email checker from Matt's Script Archive,
# with some additional checks for naughty characters and
# addresses in angle brackets.
#
sub check_email {
my ($email) = @_;
# Email is invalid if it contains: two @ signs or two consecutive dots;
# @. or .@ or it starts with a dot, or has any naughty characters.
return 0 if ( $email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$email =~ /[^\w\.\@\(\)\"\[\]\-<> ]+/g );
# If it has angle brackets, check what's in 'em. If what's outside
# is naughty, it would have been kicked out from the above test.
$email = $1 if ( $email =~ /^[^<>]*<(.*?)>$/ );
# Basic syntax requires: one or more characters before the @ sign,
# followed by an optional '[', then any number of letters, numbers,
# dashes or periods (valid domain/IP characters) ending in a period
# and then 2 or more letters (for domain suffixes) or 1 to 3 numbers
# (for IP addresses). An ending bracket is also allowed as it is
# valid syntax to have an email address like: user@[255.255.255.0]
return 0 if ( $email !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,}|[0-9]{1,3})(\]?)$/ );
return 1; # it passed
}
------------------------------
Date: Wed, 27 May 1998 16:39:00 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Email address checker - comments welcome
Message-Id: <comdog-ya02408000R2705981639000001@news.panix.com>
Keywords: from just another new york perl hacker
In article <1998052719190900.PAA12131@ladder01.news.aol.com>, mark666769@aol.com (Mark666769) posted:
>Submitted for your approval: yet another Email address
>checker from the twilight zone. Any and all
>comments and improvements would be most welcome.
># Based on an Email checker from Matt's Script Archive,
that's the first clue that it won't work.
>sub check_email {
> my ($email) = @_;
>
> # Email is invalid if it contains: two @ signs or two consecutive dots;
> # @. or .@ or it starts with a dot, or has any naughty characters.
hmmm... <two..dots@domain.tld> works with sendmail8.8.8!
hey ... so does <enddot.@domain.tld>!
no naughty characters? i think Eli gets his mail just fine. perhaps
you (not to mention the evil originator) should have looked at his
address FAQ).
and an @ sign? what about all those AOL people?
> return 0 if ( $email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
> $email =~ /[^\w\.\@\(\)\"\[\]\-<> ]+/g );
but what about addresses like "brian @ work" <comdog@computerdog.com>
"thoughts..." <topdog@computerdog.com>
> # If it has angle brackets, check what's in 'em. If what's outside
> # is naughty, it would have been kicked out from the above test.
you've already discarded deliverable addresses before you got this far.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
everyone wants a regex for something.
------------------------------
Date: Wed, 27 May 1998 21:26:38 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: file size with perl and win NT
Message-Id: <356CE77E.13A5@comenius.ms.mff.cuni.cz>
If you want a list of unique items and the sorting doesn't realy matter
you should use $hash{$the_item} = 1; instead of producing
a huge list, sorting it and then deleting the duplicates.
It is much quicker.
#!/usr/bin/perl
# BEWARE UNTESTED CODE !
my @fromFile = ("big25MbFile.txt");
my $outputFile = "allURL.txt";
my %all;
foreach $file (@fromFile) {
#reading the file entirely
open (FROM,"$file") || die " Error opening file: $file\n";
while (<FROM>) {
my @url=/(http:.*)/;
if(scalar(@url)>0) {
foreach (@url) {$all{$_}=1}
# if you use $all{$_}++ instead, you'll get the number of
occurences
}
}
close (FROM);
}
open (OUTPUT,">$outputFile") || die " Error opening file:
$outputFile\n";
print "We have ", scalar(keys %all), "unique URLs\n";
while ( ($curr,$foo) = each %all) {
# if you want it sorted you may use
# foreach $curr (sort keys %all) {
print OUTPUT $curr, "\n";
}
close (OUTPUT);
__END__
But I'm afraid this doesn't help with your main problem.
Hi, Jenda
------------------------------
Date: 27 May 1998 13:14:59 -0700
From: Evan Kirshenbaum <evan@garrett.hpl.hp.com>
Subject: Re: GNU attacks on the open software community
Message-Id: <v9hbtsjmpx8.fsf@garrett.hpl.hp.com>
trd@hydra.cs.mu.oz.au (Tyson Richard DOWD) writes:
> Evan Kirshenbaum <evan@garrett.hpl.hp.com> writes:
>
> >trd@hydra.cs.mu.oz.au (Tyson Richard DOWD) writes:
>
> >> Ron House <house@usq.edu.au> writes:
> >> >
> >> >But this is the whole problem: they did not use any recognised
> >> >meaning of the word: they made up a new meaning.
> >>
> >> No, that meaning has been in place for centuries now.
>
> >I know I really shouldn't get involved in this one, but I'm having
> >trouble coming up with another X for which "free X" can reasonably be
> >construed as "an X that anyone is free to examine, modify and make
> >available to others provided that if they do so they must provide a a
> >full description of the modified X and transfer this right"?
>
> How about being a little easier on the defintion.
>
> "An X that has no restrictions upon use".
That one doesn't appear to be in my dictionary (_Merriam Webster's
Collegiate_, 10th edition) either (out of 36 definitions), so I have
trouble believing that it "has been in place for centuries". For what
X other than "software" does "free X" mean "an X that has no
restrictions upon use"?
--
Evan Kirshenbaum +------------------------------------
HP Laboratories |I believe there are more instances
1501 Page Mill Road, Building 1U |of the abridgment of the freedom of
Palo Alto, CA 94304 |the people by gradual and silent
|encroachments of those in power
kirshenbaum@hpl.hp.com |than by violent and sudden
(650)857-7572 |usurpations.
| James Madison
http://www.hpl.hp.com/personal/Evan_Kirshenbaum/
------------------------------
Date: 27 May 1998 20:50:44 GMT
From: jstott+usenet@poly.phys.cwru.edu (Jonathan Stott)
Subject: Re: GNU attacks on the open software community
Message-Id: <6khub4$9ld$1@pale-rider.INS.CWRU.Edu>
In article <v9hbtsjmpx8.fsf@garrett.hpl.hp.com>,
Evan Kirshenbaum <evan@garrett.hpl.hp.com> wrote:
>
>That one doesn't appear to be in my dictionary (_Merriam Webster's
>Collegiate_, 10th edition) either (out of 36 definitions), so I have
>trouble believing that it "has been in place for centuries". For what
>X other than "software" does "free X" mean "an X that has no
>restrictions upon use"?
Free Will?
-JS
--
Jonathan Stott xxxxxxxxxxxxxxxxxxx jstott@poly.cwru.edu
CWRU Dept. of Physics <fakeaddr@poly.phys.cwru.edu>
School of Graduate Studies http://poly.phys.cwru.edu/~jstott/
An optimist is someone who believes Schroedinger's cat is half alive.
------------------------------
Date: Wed, 27 May 1998 21:34:42 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: HELP! - Perl Query String Encoding
Message-Id: <356CE962.769A@comenius.ms.mff.cuni.cz>
J wrote:
>
> This part of my script doesn't work because it isn't encoded:
> How would I get $newurl encoded for the web?
>
> $newurl = "http://www.domain.com/bin/script.pl?caption=hello
> there&file=./noway.jpg";
> print "Location:$newurl\n\n";
>
> Thanks!
>
> J
TIMTOWDI, as usual
use Enurl;
$newurl = 'http://www.domain.com/bin/script.pl?'
. enurl {caption => 'hello there', file => './noway.jpg'};
or
use Enurl;
use Interpolation '?' => sub (enurl({split /$;/o, $_[0]}));
# Please do not try to understand how does this work !
# Your brains may explode ;-)
$newurl = "http://www.domain.com/bin/script.pl$?{caption => 'hello
there', file => './noway.jpg'}";
See http://www.fmi.cz/private/Jenda
Cheers, Jenda
------------------------------
Date: Wed, 27 May 1998 20:36:15 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: How can I get the system memory size of my system(Linux)
Message-Id: <87vhqrfo3k.fsf@bj2-64.rh.uchicago.edu>
"Kirk D. Haines" <khaines@oshconsulting.com> writes:
> mikpf@hotmail.com wrote:
> >
> > Thanks,
> >
> > Jong
> >
> > jong@salt2.med.harvard.edu
>
> #!/usr/bin/perl
>
> use strict;
>
> open(MEM,"</proc/meminfo") || die "Something is very wrong\n";
> my $line;
> while ($line = <MEM>)
> {
> next unless ($line =~ /^Mem\w/);
> print $line;
> }
> close(MEM);
>
> gives on the system I am on now:
>
> MemTotal: 64208 kB
> MemFree: 1220 kB
> MemShared: 36248 kB
>
> i.e. this pretty much isn't a Perl issue. It's a Linux issue. Memory
> information can be read from /proc/meminfo under Linux.
A more general unixism would be to parse the output of the `free` command.
--
Peter Fein 773-834-6206
1005 E. 60th St. Chicago, IL 60637
p-fein@uchicago.edu http://pfein.home.ml.org/
------------------------------
Date: Wed, 27 May 1998 11:55:53 -0400
From: John Chambers <jc@ral1.zko.dec.com>
Subject: Re: How to create nonblocking socket in Perl ?
Message-Id: <356C3789.715F2B7B@ral1.zko.dec.com>
Sun Qinghe wrote:
>
> Hi,
>
> I want to modify the sample client program in Programming Perl so that
> I can set timeout for connect(). i.e., if the server doesn't respond in
> (say) 4 seconds, then I will give up the connection to avoid deadlock.
>
> Any help would be really appreciated.
And it would be helpful if answers would be posted rather than emailed.
I've been working on the same problem for ages, and haven't yet found a
good solution.
The obvious thing is to set up a $SIG{ALRM} handler, and call alarm($timeout)
just before the connect(). This doesn't work. I have a case in a log file
that I just looked at, where $timeout is 120, and the $SIG{ALRM} handler was
triggered at 172 seconds. This is on a nearly-idle machine (an Alpha running
Digital Unix, so it's usually idle ;-). What seems to happen is that the
connect() takes precedence over the alarm(), and the alarm only goes off
after the connect gives up. I see the same (mis)behavior on linux and several
forms of Unix. When I came in this morning, a web-search process was hung,
and its log showed no messages for 11 hours. It writes a log message before
every connect(), and it was hung on a connect. I sent it an INT signal, it woke
up, printed a stack trace, and promptly went back to being hung on the connect().
A couple of hours later, the connect() failed, the 120-second alarm went off,
and the program came back to life.
I tried putting a close() call in the INT signal handler. What it seems to
do is say "Wait until the connect finishes, and then I'll close the file."
Someone here recently suggested using eval {} to surround the connect(). This
also fails dramatically, by getting a memory fault when the alarm goes off.
And putting in a $SIG{SEGV} handler doesn't seem to have any effect at all.
If only the turkeys who brought us the BSD socket library had seen fit to
include a timeout arg to connect(), as they did with select(). You'd think
they would have realized their error and included the timeout arg in the .1
release. Or you'd think that various vendors would realize the error and
add the timeout arg themselves. Nope. This is one of the biggest problems
with writing robust web software, and nobody seems to have any intention
at all to include a timeout arg with connect(). Or fix the alarm mechanism
so that connect() doesn't block it.
Sigh.
------------------------------
Date: Wed, 27 May 1998 21:51:42 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: Invoking the Perl interpreter from DOS shell
Message-Id: <356CED5D.299D@comenius.ms.mff.cuni.cz>
Ajit Mandalay wrote:
>
> Hi,
>
> I am in the process of learning Perl, and would like to know how the
> Perl interpreter can be invoked from a file containing Perl script and
> have it interpret the script in the file in a DOS or Windows
> environment. Does the file have to have a special extension? Any
> suggestions would be highly appreciated.
>
> Thanks
> Ajit
1. DOS and Win3.x DOS prompt
You have to call perl.exe explicitly
c:\> perl script.pl
2. Win95 DOS prompt
Either call perl explicitly or associate .pl (or other extension
of your choice to perl.exe) and use the "start" command:
c:\> perl script.pl
c:\> start script.pl
The later solution will open a new window for the script's output.
3. WinNT Command Prompt (cmd.exe)
If you associate the extension you may call the scripts directly
c:\> script.pl
In addition you may set the system variable PATHEXT
to ".bat;.cmd;.pl;.com;.exe". The system will then search for all
files in the PATH and add the extension if necessary
c:\> script
4. Win3.x File Manager or Win95/NT Explorer
If you associate the extension you may double click the script
and execute it.
How to associate:
Win3.x :
Registration Info Editor (regedit.exe)
Edit\Add File Type
Identifier: Perl_script
File Type: Perl script
Command: c:\perl\bin\perl.exe %1 %*
Uses DDE: not checked
File Manager
File\Associate
Files with Extension: PL
Associate With:
Perl script
Win95/NT
Explorer/My Computer/etc
View\Options\File Types
[New]
Description: Perl script
Extension: .pl
Actions [Add]
Name: E&xecute
Application: c:\perl\bin\perl.exe "%*" %*
[OK]
[OK]
[OK]
HTH, Jenda
------------------------------
Date: Wed, 27 May 1998 16:58:25 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Job Postings
Message-Id: <comdog-ya02408000R2705981658250001@news.panix.com>
Keywords: from just another new york perl hacker
In article <356C577F.27782F86@genelogic.com>, dtyree@genelogic.com posted:
>My name is darryl tyree and I am the HR Specialist at Gene Logic Inc. I
>would like to know what I need to do to place job openings on your site?
print "okay to post" if $newsgroup =~ m/\.jobs?\./;
print "not okay to post" if $newsgroup =~ m/\Qcomp.lang.perl.misc\E/;
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
let me add you to the killfile just in case :)
------------------------------
Date: 27 May 1998 20:48:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: list context: || vs or
Message-Id: <6khu6b$6gt$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6kfepa$c4h$1@csnews.cs.colorado.edu>:
> Beyond that, you cannot have a "list in scalar context". This is
> like dividing by 0. It can't happen. The universe will not allow it.
<NITPICKING>
If your universe does not allow this, do not press it on us. In my
universe dividing by 0 is well-defined in many cases.
</NITPICKING>
Ilya
------------------------------
Date: Wed, 27 May 1998 16:05:49 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Modules in Perl
Message-Id: <comdog-ya02408000R2705981605490001@news.panix.com>
Keywords: from just another new york perl hacker
In article <356c4ee4.2655294@news.btinternet.com>, Gellyfish@btinternet.com posted:
>On Wed, 27 May 1998 15:56:57 GMT, J wrote :
>
><snip>
>
>>but every time I include this in the script the server throws back a 500
>>Error......
>Either of these will print some diagnostic stuff to your browser.
i heard The Perl Journal had an article about this ;)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers T-shirts! <URL:http://www.pm.org/tshirts.html>
The Perl Journal <URL:http://www.tpj.com>
------------------------------
Date: Wed, 27 May 1998 22:00:09 -0700
From: Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz>
Subject: Re: Modules in Perl
Message-Id: <356CEF59.5B20@comenius.ms.mff.cuni.cz>
J wrote:
>
> Sorry for bugging....
>
> I'm using Website running with Perl5 installed... (and now Escape.pm)
> am trying to call it from a perl script using
>
> use URI::Escape
>
> but every time I include this in the script the server throws back a 500
> Error......
> the script is being used to grab a reference number (ie: hmr00001) from
> QUERY_STRING and search a database, pull out the relevant information then
> call a second script as follows:
> createhtml.pl?a=1&b=2&caption=Hello There My
> Son&Filename=http://www.domain.com/images/crap.jpg
>
> what am I doing wrong?
>
> J
Is it working from command prompt?
What error messages do you get if it is not?
Where did you place Escape.pm?
A little more info is needed.
Jenda
------------------------------
Date: 27 May 1998 19:12:04 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Need a "word-count"
Message-Id: <6khoi4$9he$1@csnews.cs.colorado.edu>
:Fully aware of your fetish in this regard,
I do not think that word means what you think it does.
I missed the attribution.
:Yes. I (and perhaps others) have profitted from this (newly revealed?)
:insight.
Good.
:Are you quite sure that the Wall quotes are random? This one seems very
:much to the point :-).
Yes, they are random.
--tom
#!/usr/bin/perl
#
# sigrand -- supply random fortunes for .signature file
################################################################
# begin configuration section
$MKNOD = "/bin/mknod";
$SIG{PIPE} = IGNORE; # idiot vi
&gethome;
# for rec/humor/funny instead of rec.humor.funny
$NG_IS_DIR = 1;
$FULLNAME = "$HOME/.fullname";
$FIFO = "$HOME/.signature";
$ART = "$HOME/.article";
$NEWS = "$HOME/News";
$SIGS = "$NEWS/SIGNATURES";
$SEMA = "$HOME/.sigrandpid";
$GLOBRAND = 1/4; # chance to use global sigs anyway
# end configuration section -- HOME and FORTUNE get autoconf'd
################################################################
&setup;
&justme;
#fork && exit; # be a daemon
open (SEMA, ">$SEMA") || die "can't write $SEMA: $!";
print SEMA "$$\n";
close SEMA || die "can't close $SEMA: $!";
MAIN: while (1) {
open (FIFO, "> $FIFO") || die "can't write $FIFO: $!";
&load_sigs;
$sig = $sig[rand @sig];
#print FIFO $name, "\n" x (3 - ($sig =~ tr/\n//)), $sig;
print FIFO $sig;
close FIFO;
#sleep 2;
# i don't know why, but if i don't do this, the open
# happens so fast people get multiple signatures.
# 1/100th of a second seems enough
select(undef, undef, undef, 0.1);
}
die "NOT REACHED";
################################################################
sub setup {
if (-e $FULLNAME) {
$name = `cat $FULLNAME`;
die "$FULLNAME should contain only 1 line, aborting"
if $name =~ tr/\n// > 1;
} else {
chop($host = `hostname`);
($host) = gethostbyname($host) unless $host =~ /\./;
$user = $ENV{USER} || $ENV{LOGNAME} || $pw[0] || die "intruder alert";
($name = $pw[6]) =~ s/,.*//;
$name =~ s/&/\u\L$user/g; # can't believe some folks still do this
$name = "\t$name\t$user\@$host\n";
}
&check_fortunes if !-e $SIGS;
unless (-p $FIFO) {
if (!-e _) {
system("$MKNOD $FIFO p") && die "can't mknod $FIFO";
warn "created $FIFO as a named pipe\n";
} else {
die "$0: won't overwrite file .signature\n";
}
}
srand(time|$$);
}
sub load_sigs {
local($sigfile) = &ng;
if (!-e $sigfile) {
@sig = (&fortune);
return;
}
open (SIGS,$sigfile) || die "can't open $sigfile";
local($/) = "%%\n";
undef @sig;
while (<SIGS>) {
s!$/$!!o;
push(@sig,$_);
}
close SIGS;
}
sub ng {
(rand(1.0) > ($GLOBRAND) && open ART) || return $SIGS;
local($/) = '';
$_ = <ART>;
($ng) = /Newsgroups:\s*([^,\s]*)/;
$ng =~ s!\.!/!g if $NG_IS_DIR; # if rn -/, or SAVEDIR=%p/%c
$ng = "$NEWS/$ng/SIGNATURES";
-f $ng ? $ng : $SIGS;
}
sub fortune {
local($_, $tries);
do {
$_ = `$FORTUNE -s`;
} until tr/\n// < 5 || $tries++ > 20;
local($*) = 1;
s/^/ /g;
$_ || " SIGRAND: deliver random signals to all processes.\n";
}
sub check_fortunes {
return if $FORTUNE;
foreach $dir (split(/:/, $ENV{PATH}), '/usr/games') {
return if -x ($FORTUNE = "$dir/fortune");
}
die "Need either $SIGS or a fortune program, bailing out";
}
sub gethome {
@pw = getpwuid($<);
$HOME = $ENV{HOME} || $ENV{LOGDIR} || $pw[7]
|| die "no home directory for user $<";
}
# "There can be only one." --the Highlander
sub justme {
if (open SEMA) {
chop($pid = <SEMA>);
kill(0, $pid) && die "$0 already running (pid $pid)\n";
#warn "COOL: no $pid: $!";
close SEMA;
}
}
--
I don't believe it's written in Perl, though it probably
ought to have been. :-)
--Larry Wall in <1995Feb21.180249.25507@netlabs.com>
------------------------------
Date: Wed, 27 May 1998 13:07:24 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Need a "word-count"
Message-Id: <6khrpl$d9u@hplntx.hpl.hp.com>
[posted and emailed]
Tom Christiansen wrote in message
<6khoi4$9he$1@csnews.cs.colorado.edu>...
>:Fully aware of your fetish in this regard,
>
>I do not think that word means what you think it does.
A fetish is an object. Better would be "fetishism 2: extravagant
irrational devotion". Yet you omitted
[courtesy cc of this posting sent to cited author via email]
in this post!
>I missed the attribution.
I guess that's as close as I'll come to getting an apology for being
called "evil".
...
>:Are you quite sure that the Wall quotes are random? This one seems
very
>:much to the point :-).
>
>Yes, they are random.
>
>--tom
...
I knew they were, hence the smiley. However, thanks for posting the
code. Reading expert code is very worthwhile. Everyone will benefit
from your cookbook when it is published.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Wed, 27 May 1998 11:17:30 -0400
From: John Chambers <jc@ral1.zko.dec.com>
Subject: Re: new to OO Perl
Message-Id: <356C2E8A.B8DE906F@ral1.zko.dec.com>
John Porter wrote:
>
> I know you said you've returned to doing this "the old way",
> but you may as well learn how to do it the OO way; it's
> good stuff, you know. No need to get frustrated.
...
> Make the following substitutions throughout your code:
> In place of: Use:
> $props{$key} $self->{'props'}{$key}
> %props %{$self->{'props'}}
> $format[$index] $self->{'format'}[$index]
> @format @{$self->{'format'}}
> (for all values of $key and $index)
Thought I'd toss out an analysis of this and see if I can get
some reasoned replies. What strikes me in examining the right
column is that in each case, there is one extra hash-table
lookup. In the left column, the 'props' and 'format' symbols
can be looked up once at compile time, and the object code can
contain a direct pointer to the object. In the right column, it
looks like the lookups happen at run time. (Though a clever use
of optimization techniques could produce a fixed-format hash
table for all instances of $self and use a fixed offset, I've
yet to see a hint that perl contains such an optimizer.)
>From my experiences writing compilers and interpreters, this
flips up a big red flag. Table lookups are expensive, typically
hundreds of times the cost of an add or multiply. Compilers and
interpreters typically spend more than half their cpu time doing
table lookups. Even a good hash algorithm (and perl does seem
to have a good one) is expensive. If you are interested in the
best performance, table lookups are always the first place you
look, and if you can eliminate them, you always gain a significant
speed increase.
So I'd expect that the code in the right column would produce
a significant performance hit. The OO approach is, of course,
notorious for producing incredibly bad performance, except for
a few cases where the programmers really understand it and know
the performance gotchas. But just telling programmers to "Use
this marvelous new approach; it'll solve all your problems" is
often a performance disaster, because of issues like this.
Any comments? What does a programmer need to know about how
perl does OO, so as to avoid the performance hit from extra
run-time table lookups?
(Note that I'm not casting aspersions on perl's hash tables.
I use them a lot, and I like to use them as an example of how
perl includes some powerful ideas in a very simple fashion.
But I also find them useful as an example of something that
can be easily misused by programmers who don't appreciate the
complexity and time cost hidden behind that simple-looking
$x{$y} indexing notation.)
------------------------------
Date: Wed, 27 May 1998 12:13:34 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Okay, NOW I'm confused (redirect)
Message-Id: <6khokm$cg5@hplntx.hpl.hp.com>
[posted and emailed]
Phil Buckley wrote in message <356c5897.23593974@News.Varian.COM>...
...
>$host = "$ENV{'REMOTE_HOST'}";
The double quotes are not needed or advisable here, though that's not
your problem!
>
>$packed_ip_addr = pack ("C4", $host =~
>/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
>if ($host = gethostbyaddr $packed_ip_addr, 2) { # If they are coming
>from Varian
Here you are assigning the value returned by gethostbyaddr to $host, not
comparing it. This expression will be TRUE any time gethostbyaddr
succeeds. The comparison operator is 'eq'. (In fact, you probably want
to compare only the latter part of it, as discussed here earlier.)
I would change $ENV{REMOTE_HOST} to $ENV{REMOTE_ADDR}, or at least check
that your match against an IP address succeeded before calling
gethostbyaddr. Then I would store the result of gethostbyaddr and check
it first for 'defined' (returns FALSE if it fails).
Then, after all the Perl problems are gone, if it still doesn't work the
way you expect, I'd continue the inquiry via a CGI newsgroup. :-)
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 2738
**************************************