[13383] in Perl-Users-Digest
Perl-Users Digest, Issue: 793 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 14 13:07:25 1999
Date: Tue, 14 Sep 1999 10:05:17 -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, 14 Sep 1999 Volume: 9 Number: 793
Today's topics:
ANNOUNCE: Champaign-Urbana Perl Mongers meeting Thu Sep (Daniel S. Lewart)
Re: Anyone know what "premature script header means"? (Bill Moseley)
Re: CGI Oracle problem (John D Groenveld)
challenge results <srooij@wins.uva.nl>
Re: Cookies & IE 5.0 (Kragen Sitaker)
Re: Creating a File with Username and password dmcp71@my-deja.com
Critique/comments for web board? (David Wall)
Re: Design Advice needed on Sending Data to Client caitlynhay@my-deja.com
Re: Design Advice needed on Sending Data to Client caitlynhay@my-deja.com
Re: Design Advice needed on Sending Data to Client (Kragen Sitaker)
Re: Faxing Script (Michael Budash)
Generating an email with form entry (CGI) <jgmtest@serviceteam.ltd.uk>
Re: Generating an email with form entry (CGI) (Kragen Sitaker)
Help with compiling a list jsilve1@my-deja.com
Hiding Database password in a CGI script. <berreb@email.com>
Re: Hiding Database password in a CGI script. (Kragen Sitaker)
Re: Hiding Database password in a CGI script. <jamie@mccarthy.org>
Is it possible ... ? (keywords: socket, sysread, buffer <zed@Artis.Uni-Oldenburg.DE>
Re: Is it possible ... ? (keywords: socket, sysread, bu (Kragen Sitaker)
Re: Is perl Safe? (Mike Smith)
libwww-perl <customk9@home.com>
Re: opening files/secure server (Kragen Sitaker)
Re: Perl / C Memory <dan@tuatha.sidhe.org>
Re: Perl / C Memory <dan@tuatha.sidhe.org>
Re: Perl and Threads <dan@tuatha.sidhe.org>
perl ext .cgi with MS PWS kshagen@my-deja.com
Re: perl ext .cgi with MS PWS (Kragen Sitaker)
Re: Perl Y2k <aqumsieh@matrox.com>
PLEASE HELP! - Symbolic References makau@multimania.com
Pre-release Beta Testers <examtesting@recruitsource.com>
Re: Searching by date problem. (Larry Rosler)
Re: Sweep several txt files into 1 big txt file....... (Kragen Sitaker)
Re: syslog / linux <SternSZ@gmx.de>
Re: syslog / linux <rra@stanford.edu>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Sep 1999 15:07:33 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: ANNOUNCE: Champaign-Urbana Perl Mongers meeting Thu Sep 16
Message-Id: <7rlobl$nc1$1@vixen.cso.uiuc.edu>
Champaign-Urbana Perl Mongers,
By popular demand, we shall meet:
Thu Sep 16 19:00-21:00 CDT
The Bread Company on Goodwin
706 S Goodwin Ave
Urbana, IL
FYI, Bloomington/Normal will establish a new Perl Mongers group soon.
Bring Your Own Code,
Daniel Lewart
Champaign-Urbana Perl Mongers Tsar
http://cmi.pm.org/
------------------------------
Date: Tue, 14 Sep 1999 08:33:08 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Anyone know what "premature script header means"?
Message-Id: <MPG.12480a8d3b02bfe7989747@nntp1.ba.best.com>
Lisa Saari (sculptural@aol.comnojunk) seems to say...
> My scripts aren't going through and are instead coming back with a 500-Internal
> Server Error message. It does tell me that the script has "a premature script
> header". Can someone please respond ASAP!
It means go to http://www.deja.com and search!
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: 14 Sep 1999 12:59:40 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: CGI Oracle problem
Message-Id: <7rluts$3c8$1@grolsch.cse.psu.edu>
When you run the script from the command line, as the user nobody, with no
environment variables set do you get the same results?
Perhaps you have and environment problem:
http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
John
groenveld@acm.org
------------------------------
Date: Tue, 14 Sep 1999 18:57:01 +0200
From: Steven de Rooij <srooij@wins.uva.nl>
Subject: challenge results
Message-Id: <37DE7E5D.1C172E3E@wins.uva.nl>
Results triple challenge tight coding
-------------------------------------
For assignments 2 and 3, I was expecting full Unix statements, in
which the predictable 'perl -ne' beginning _does_ count. I removed
superfluous spaces in the code of those people who didn't realise that
the 'perl ..' part counts as well.
The first assignment was a bit ambiguous: I asked you to write a
`program', by which I meant a separate file that was called either
without command line switches or with command line switches on the
shebang line, which would also be counted. But the two solutions I was
sent didn't have this format. They were, on the other hand, all easy
to convert to command line statements which is what I did to be able
to compare them. So all programs are assessed in the same way.
I didn't specify an output format because I didn't want to impose any
other restrictions on the programs than size. The only program I
disqualified was Gareth Rees's Program A:
while(<>){print if$w{join"",sort split""}++}
This does search for anagrams, but it prints only the second and
subsequent words from each set of anagrams, which is not what I had in
mind obviously. But as I said, the challenge was a bit ambiguous and
I should have been more specific.
Here are the winning programs:
--------------------
1. Write the shortest possible Perl program that finds anagrams in a
word list.
The shortest complete program was by Gareth Rees.
The program prints 'anagram pairs', so they come two at a time. It's
not the output you'd expect of an anagram searcher, but they're all in
there, so it's okay. Here it is:
perl -ne'print$$w,$_ if${$w=\$w{join"",sort split""}};$$w=$_' [61]
The second best program was by David Alan Black, who wrote:
perl -ne'push@{$w{join"",sort split""}},$_;END{$#$_&&print@$_ for
values%w}' [76]
Steven Alexander ended third, with two equally good solutions:
perl -lne'$x{join"",sort split//}.=" $_";END{$,=$/;print grep/ .*
/,values%x}' [78]
perl -aF// -lne'$x{join"",sort@F}.=" $_";END{$,=$/;print grep/ .*
/,values%x}' [78]
My own solution finishes last:-(
perl -e'for(<>){chop;push@{$h{join"",sort
split//}},$_}for(%h){print"@$_\n"if@$_>1}' [84]
--------------------
2. Find the shortest possible Unix command that finds all palindromes
in a wordlist.
The winner was Steven Alexander with:
perl -lne'reverse eq$_&&print' [30]
Second place is Abigail, only just a little bit less sharp:
perl -nle'$_ eq reverse&&print' [31]
Third place is Gareth Rees with:
perl -lne'print if$_ eq reverse$_'
Last and certainly least is my sad program:
perl -ne'print if"\n$_"eq reverse."\n"' [39]
--------------------
3. Write the shortest possible Unix command that find words in a
wordlist that occur both forwards and backwards.
Ha! Got you there. I end first place with a solution you didn't think
of:
rev file|sort|sort file -|uniq -d [33]
(Where `file' is the name of the file you want to process. It would have
been neater to process stdin, but I feel this can't be held against me.
I spent a generous 8 bytes spelling out a realistic filename twice).
Note that you can tack a -m on the second `sort' to improve the speed
if you have an alphabetically ordered input file.
Second is `Abigail' with this amazing piece of perl code:
perl -nle'$_{$_}++}{$_{+reverse}&&print for keys%_' [51]
======================
Conclusions:
Not knowing about the -l switch is a handicap if you try to write short
Perl code. Also I forgot to use `for' as a modifier in my first program.
A trick that everyone except me used was to call perl -ne and then
create
an END block, but only Abigail knew to compress that even more, which is
why he should have won the third contest :-)
Sadly only the author of the worst anagram program (me), realised that
you can omit the `values' call because the keys of the hash never
contain
multiple values so they won't be printed anyway.
If I combine all the new tricks I learned from the solutions I was sent
(as in accordance with Perl culture), I can improve a little more on
the anagram program.
The following gem is the result of the joint efforts of Abigail,
Steven Alexander, David Alan Black, Gareth Rees and me:
(Everything on a new line:)
perl -ne'$x{join"",sort split//}.=$_}{/.\n./&&print for%x'
(All anagrams on one line:)
perl -lne'$x{join"",sort split//}.="$_ "}{/ ./&&print for%x'
If anyone knows how to squeeze another byte out of this I will start
uttering strange sounds.
Steven de Rooij
------------------------------
Date: Tue, 14 Sep 1999 16:43:37 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Cookies & IE 5.0
Message-Id: <ZWuD3.10296$N77.791959@typ11.nn.bcandid.com>
In article <7r3ubp$4so$1@nnrp1.deja.com>, <fabaroa@my-deja.com> wrote:
>I have used this code for a few years and it has
>worked fine. But Internet Explorer 5.0 doesn't
>seem to record this cookie. Anyone know why and
>what I do?
Ask in a relevant newsgroup. comp.lang.perl.misc isn't it.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 16:27:19 GMT
From: dmcp71@my-deja.com
Subject: Re: Creating a File with Username and password
Message-Id: <7rlt0r$p41$1@nnrp1.deja.com>
In article <LQcD3.8559$N77.659875@typ11.nn.bcandid.com>,
kragen@dnaco.net (Kragen Sitaker) wrote:
> In article <7rji0b$39f$1@nnrp1.deja.com>, <dmcp71@my-deja.com> wrote:
> >What I need
> >to do is to create a login page with a username, email address and
> >password. When the user enters their name, username and email
address,
> >a file is created for them using their username and password with
> >either a unique id number or something similar that will allow them
to
> >enter additional information and retrieve it whenever they want.
>
> Which part of this are you having trouble with? Creating the login
> page, creating user accounts, storing additional information,
verifying
> logins, what?
>
> Kragen
> --
> <kragen@pobox.com> Kragen Sitaker
<http://www.pobox.com/~kragen/>
> Mon Sep 13 1999
> 56 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
>
I have no problem creating the login page. My problem is creating the
user accounts, storing the additional data for those accounts and
verifying the information. I am very new to perl, so this is not any
easy task for me, I was hoping someone could inform me of where I could
find the information to do this or provide me with some tips. Thanks
in advance for your help.
DC
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 16:23:58 GMT
From: darkon@one.net (David Wall)
Subject: Critique/comments for web board?
Message-Id: <37de76f8_1@news2.one.net>
Keywords: Perl, web board, BBS, critique, DarkBoard
I wrote a little web BBS (in Perl, of course) for fun, and have it posted at
http://w3.one.net/~darkon/darkboard/. It's nothing fancy, just a toy project,
but if anyone here would like to take a look at it and offer useful
suggestions on improving my code, I'd appreciate it. I'm not a professional
programmer, so it's entirely possible that I may be doing things the hard way
when there's a pre-existing method. Of course, I may have just done some
stupid things in my code. In any case, I tried to comment it so that it could
be read easily.
So... comments, anyone?
David Wall
darkon@one.net
------------------------------
Date: Tue, 14 Sep 1999 15:05:07 GMT
From: caitlynhay@my-deja.com
Subject: Re: Design Advice needed on Sending Data to Client
Message-Id: <7rlo6r$lev$1@nnrp1.deja.com>
Hi Ron,
Thx for your reply. The clients are Windows
based VC++ or VB program. The server side is
UNIX based. The reason I choose http is because
that seems the most reasonable. Ftp connection
won't make sense here because the server is not
sending back a file but a dynamic array. Are
there any other alternatives?
Thx,
cait
In article
<7rig1i$3db$1@news.hstn.tensor.pgs.com>,
rong@news.pgs.com (Ron Grunwald-Computer
Programmer PGS Tensor Perth) wrote:
> Caitlyn Hay (caithay@hotmail.com) wrote:
> : I'm new to internet programming. I have to
write a server program that
> : interacts with a client program. Basically,
the client program will submit
> : a criteria to the server via a http
connection. Based on this criteria, the
> : server will generate some ASCII formated
data, and return it (the ASCII
> : data) back to the client.
>
> : What is the standard way of doing this? My
first thought was to send the
> : ASCII data back to the client line by line.
But then, how would the client
> : know how many lines there are? On second
thought, maybe I can save the
> : ASCII data to a temp file, and let the client
download it. But then, what
> : if there are more than one client request
with different criteria - that
> : means I have to generate different files.
All these questions pop up, I
> : need to know the standard way of doing this?
>
> : Any resources would be appreciated.
> : TIA
> : cait
>
> I think sockets programming would be the ideal
approach to your problem.
> Sockets are easy to create and interacting with
them using Perl is as
> simple as:
>
> $buffer = <SOCKET>; # Reading incoming
data.
> print SOCKET $buffer; # Writing outgoing
data.
>
> I've got an 11-page document titled "Sockets
Programming Guide", which is a
> very good concise document, but unfortunately
I've only got it postscript
> format. I can mail it to you if you need it.
>
> Does your server and client have to interact
via the HTTP protocol, because
> that would imply a CGI-based approach ?
>
> Cheers, Ron.
>
> ------------------------------------------------
--------------------------
> Ron Grunwald | Usual E-
mail rong@prth.pgs.com
> UNIX Programming Section | Alternate E-
mail r.grunwald@usa.net
> PGS Tensor Pty. Ltd. | Work
Tel. 011 618 9320 9029
> Petroleum Exploration and | IBM Centre, Perth
> Seismic Processing. |
Western Australia
> ------------------------------------------------
--------------------------
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 15:05:09 GMT
From: caitlynhay@my-deja.com
Subject: Re: Design Advice needed on Sending Data to Client
Message-Id: <7rlo6s$lf0$1@nnrp1.deja.com>
Hi Kragen,
Thx for your reply. I think I'll write the data
back to the client line by line in text mode.
That seems to be the simplest.
I've simulated a client (Windows based) to test
the server program. Everything works fine except
that I'm unable to query the header info.
Is there any special header that I suppose to set
at the client or the
server side in order to get the response header?
TIA
cait
In article <5w6D3.7538
$N77.609667@typ11.nn.bcandid.com>,
kragen@dnaco.net (Kragen Sitaker) wrote:
> In article <QVgC3.2461
$x7.56225409@nr1.ottawa.istar.net>,
> Caitlyn Hay <caithay@hotmail.com> wrote:
> >What is the standard way of doing this?
>
> Using HTTP, which includes several increasingly
awful, but
> well-supported, ways of solving the problems
you mention.
>
> >All these questions pop up, I
> >need to know the standard way of doing this?
>
> See the HTTP/1.1 definition:
> http://www.normos.org/ietf/rfc/rfc2068.txt
>
> It's about 160 pages, so you should be able to
finish it in just a few
> hours.
>
> --
> <kragen@pobox.com> Kragen Sitaker
<http://www.pobox.com/~kragen/>
> Thu Sep 09 1999
> 60 days until the Internet stock bubble bursts
on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 16:17:03 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Design Advice needed on Sending Data to Client
Message-Id: <3yuD3.10269$N77.788462@typ11.nn.bcandid.com>
In article <7rlo6s$lf0$1@nnrp1.deja.com>, <caitlynhay@my-deja.com> wrote:
>I've simulated a client (Windows based) to test
>the server program. Everything works fine except
>that I'm unable to query the header info.
>
>Is there any special header that I suppose to set
>at the client or the server side in order to get the response header?
I don't understand your question.
What headers are you trying to read? Are they not being sent to the
client? If they are not being sent to the client, in what sense do
they exist at all?
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 08:56:03 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Faxing Script
Message-Id: <mbudash-1409990856030001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <19990914093726.01474.00000040@ng-cp1.aol.com>,
bbirthisel@aol.com (Bbirthisel) wrote:
>Hi Martien and Rich:
>
>>For win32 you should be able to treat your fax as a printer, but how
>>you pass it the required parameters is specific to the software etc.
>>Maybe ActiveState has some win32 specific faxing modules.
>
>Probably not as a printer without special drivers of some sort.
>There is a contributed example using Win32::SerialPort on
> http://members.aol.com/bbirthisel/alpha.html
>
>I haven't used it, so I can't say how well it works. ActiveState
>does not have anything for faxing (or for serial ports) listed on
>their site.
>
>On un*x, efax has a command-line interface that would work
>with system().
i went to efax.com and saw nothing about such a un*x interface - where did
you find out it exists?
tia-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Tue, 14 Sep 1999 07:23:44 +0100
From: "JGM" <jgmtest@serviceteam.ltd.uk>
Subject: Generating an email with form entry (CGI)
Message-Id: <eRtD3.24$cm.720@wards>
Hi all,
I have a form which feeds into a .csv file. What I want though, is an email
to be generated when the form is submitted ie. to alert relevant people that
a new entry has been made.
I used net::smtp to test the email and it works fine from the command
prompt, but I can't translate that success to the web page.
I am running ActivePerl on a NT4 server with IIS3.
Here is the script, which as I say works fine from the command prompt, but I
can't get it to run from a web page:
use Net::SMTP;
$smtp = Net::SMTP->new('myservername'); # connect to an SMTP server
$smtp->mail( 'user@here.com' ); # use the sender's address here
$smtp->to('me@myaddress.ltd.uk'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: you\@there.com\n");
$smtp->datasend("From: user\@here.com\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Hello, World!\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
Many thanks
James
------------------------------
Date: Tue, 14 Sep 1999 16:45:24 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Generating an email with form entry (CGI)
Message-Id: <EYuD3.10299$N77.790336@typ11.nn.bcandid.com>
In article <eRtD3.24$cm.720@wards>, JGM <jgmtest@serviceteam.ltd.uk> wrote:
>I used net::smtp to test the email and it works fine from the command
>prompt, but I can't translate that success to the web page.
What happens?
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 15:21:30 GMT
From: jsilve1@my-deja.com
Subject: Help with compiling a list
Message-Id: <7rlp5d$mah$1@nnrp1.deja.com>
Dear Perl Gurus:
Actually, my question is probably more algorithm-oriented rather than
perl-specific, but since i'm writing the script in perl...enuff preface.
I want to take a database of names and email addresses and extract
mailing lists based on user input (this is a cgi script for a website).
the data is compiled thus:
group firstn lastn email
=============================
PI John Smith js@blah.edu
STAFF Jane Doe jdoe@fun.place.edu
PI Betty Tooth Btooth@school.edu
etc...
Now, some of these people are in more than one "group", e.g. different
committees, that I want to be able to extract based on what group a user
chooses to have email listed for.
How could I have a person with more than one group be listed as having
more than one group, without having multiple entries for that person in
the database?
I tried something like:
STAFF,COMMITTEE_A Fred Beagle fbeagle@usa.school.edu
but I am having trouble getting the script to recognize this first field
as containing two separate groups.
Please reply with pseudocode, real perl code, or other insight or
suggestions, Thanks!!
-Jeffrey Silverman
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 15:10:11 GMT
From: David Berrebi <berreb@email.com>
Subject: Hiding Database password in a CGI script.
Message-Id: <7rlog9$lq5$1@nnrp1.deja.com>
I have a perl script which connects to a database using DBI:DBD.
The script is currently executed as user nobody and has r+x access for
the world.
In the script I defined 2 variables the dblogin and dbpassword.
My problem is if somebody connects to the unix box where the script is,
he can read the
file and find out the login and password to connect to the database.
How can I hide that information?
--
*****************************************
David Berrebi
*****************************************
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 16:37:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Hiding Database password in a CGI script.
Message-Id: <TQuD3.10284$N77.791253@typ11.nn.bcandid.com>
In article <7rlog9$lq5$1@nnrp1.deja.com>,
David Berrebi <berreb@email.com> wrote:
>My problem is if somebody connects to the unix box where the script is,
>he can read the
>file and find out the login and password to connect to the database.
Don't make the script readable and executable by everybody. Instead,
make it owned by you and readable and executable only by you.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 12:14:05 -0400
From: Jamie McCarthy <jamie@mccarthy.org>
Subject: Re: Hiding Database password in a CGI script.
Message-Id: <37DE744D.3A9BD880@mccarthy.org>
David Berrebi wrote:
> I have a perl script which connects to a database using DBI:DBD.
> The script is currently executed as user nobody and has r+x access for
> the world.
> In the script I defined 2 variables the dblogin and dbpassword.
>
> My problem is if somebody connects to the unix box where the script is,
> he can read the
> file and find out the login and password to connect to the database.
>
> How can I hide that information?
You can't. If the computer can figure out from your script what
the password is, so can a sufficiently intelligent human. Your
only recourse is to make sure the human can't read the script.
I would suggest you look into creating a user specific to your
database, instead of "nobody," who owns and runs the script.
(And turning off r+x for the world, obviously.) For example,
when I set up Apache, I configure it to run as the special user
"apnobody" which has no permissions outside the web tree and
which nothing else on the machine runs as. But this is a unix
security question, not a perl question.
Of course, feel free to try disguising the password within your
perl script as best as possible, so the casual reader won't
figure it out by grepping on "password". But if your secret is
important, you'll have to do more.
--
Jamie McCarthy
------------------------------
Date: Tue, 14 Sep 1999 17:26:11 +0200
From: zed <zed@Artis.Uni-Oldenburg.DE>
Subject: Is it possible ... ? (keywords: socket, sysread, buffer)
Message-Id: <37DE6913.FCA2B188@Artis.Uni-Oldenburg.DE>
Hi all,
Look at this:
$sh = IO::Socket::INET -> new (some args); # open a socket-handle
print $sh "GET URI HTTP/x.x"; # sending any request
###########################
# I want to do some things here and only
# read data from the socket if there is
# waiting some...
###########################
if (somebody finds a solution) {
$sh -> sysread ($buf, $size, lenght($buf)); # reading the answer
} # $size - in this context - seems only to be a max value...
__END__
It seems to me, that incoming data for a (tcp) socket is buffered...
questions:
* is it possible to read the length of data, which is waiting for sysread (without using sysread)...?
* how can I manipulate the length of the buffer of the socket?
I didn't get setbuf() or setvbuf() to work...
problems:
* I've got no intention to fork my process ... !!!
* it seems to me, if there is no data waiting, sysread makes no progress and the wohle programm stops for several seconds!
Please help me...
--
<-]{][o->
PS: if you think I am a newbie, you may tell me... <g>
ciao... : )
------------------------------
Date: Tue, 14 Sep 1999 16:40:39 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Is it possible ... ? (keywords: socket, sysread, buffer)
Message-Id: <bUuD3.10288$N77.791659@typ11.nn.bcandid.com>
In article <37DE6913.FCA2B188@Artis.Uni-Oldenburg.DE>,
zed <zed@Artis.Uni-Oldenburg.DE> wrote:
>if (somebody finds a solution) {
> $sh -> sysread ($buf, $size, lenght($buf)); # reading the answer
>} # $size - in this context
>- seems only to be a max value...
Yes, that's right.
>It seems to me, that incoming data for a (tcp) socket is buffered...
No. Well, it's buffered by the kernel until you read it with sysread() :)
>* is it possible to read the length of data, which is waiting for
>sysread (without using sysread)...?
recvmsg, I think, with MSG_PEEK. But why bother, if it's TCP?
>* how can I manipulate the length of the buffer of the socket?
> I didn't get setbuf() or setvbuf() to work...
Dunno. Why do you want to?
>* I've got no intention to fork my process ... !!!
>* it seems to me, if there is no data waiting, sysread makes no progress
>and the wohle programm stops for several seconds!
Yes. You can set the socket to nonblocking, in which case read will
return an error (EWOULDBLOCK aka EAGAIN) if you try to read when
there's no data, or you can use select. perldoc perlipc.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 14:26:41 GMT
From: mike.smith@nats.co.uk (Mike Smith)
Subject: Re: Is perl Safe?
Message-Id: <37de5a29.2022722@news.virgin.net>
I was hoping some of that work had gone on previously so that I
wouldnt have to do that work.
I can review the test suite no problem, but I dont really want to
expend the effort of code inspection/coverage test/unit test the whole
thing myself if someone else has done it.
The reason I asked is because we are using it to write test tools to
validate the UKs new Air Traffic Control System and the process my
system integrity team have set up states that tools have to have gone
through a proper software lifecycle.
Looks like I can see a concession on the horizon.
Mike.
On Tue, 14 Sep 1999 01:53:18 -0400, "Ethan H. Poole"
<ehpoole@ingress.com> wrote:
>David Cassell wrote:
>>
>> Mike Smith wrote:
>> >
>> > Hi all,
>> >
>> > We use Perl as a tools to help us wade through all of our data on our
>> > project. My System Integrity team are asking how do I know that perl
>> > is safe, has it been trough code inspection, unit test, coverage test
>> > etc.
>> > Can anyone help? What is the update process for perl.
>>
>> Perl comes with test suites. It goes through testing before
>> beta versions become the next 'stable' version. The perlhist
>> doc has some info on that. [Not that there are not slips
>> now and then - Perl isn't perfect.]
>>
>> How do you know that your System Integrity Team is safe?
>
>Perl even goes a step further, everyone who wishes may download the source
>code for Perl, review it in-house if they wish, and then compile the
>reviewed code for themselves.
>
>If that doesn't satisfy your Systems Integrity Team, they had better start
>unplugging the computers because things don't get much more open than open
>source projects -- and you had better start firing the Team and looking
>for some replacements!
>
>--
>Ethan H. Poole **** BUSINESS ****
>ehpoole@ingress.com ==Interact2Day, Inc.==
>(personal) http://www.interact2day.com/
------------------------------
Date: Tue, 14 Sep 1999 15:55:54 GMT
From: "Don Stefani" <customk9@home.com>
Subject: libwww-perl
Message-Id: <eeuD3.11735$Vi5.163314@news1.frmt1.sfba.home.com>
I have a perl script that I found that says it depends heavily on the
libwww-perl.
I went and got the libwww-perl tar file. How should the libwww-perl be
installed, all of it of just part?
How should my file be installed in relation to the libwww-perl?
Thank you,
Don Stefani
------------------------------
Date: Tue, 14 Sep 1999 16:53:52 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: opening files/secure server
Message-Id: <A4vD3.10317$N77.793283@typ11.nn.bcandid.com>
In article <37D55127.AD63C6AC@cris.com>,
Perfect Beat <prfctbt@cris.com> wrote:
>I am having a problem opening files for writing from a secure server.
>The process works fine while in non secure mode using relative paths. I
>have tried to use absolute http and https paths but am not having any
>luck. Does anyone have some insight?
You probably have a bug.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 16:04:35 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl / C Memory
Message-Id: <nmuD3.13465$wW2.11607@news.rdc1.ct.home.com>
Alan Curry <pacman@defiant.cqc.com> wrote:
> In article <hzUC3.5897$wW2.8602@news.rdc1.ct.home.com>,
> Dan Sugalski <dan@tuatha.sidhe.org> wrote:
>>Kai Henningsen <kaih=7OhjZZ$mw-B@khms.westfalen.de> wrote:
>>> The way to do that is to not use brk(), but instead use mmap() to get the
>>> memory. Then you can munmap() it again.
>>
>>Well, OK, you can do that with any OS that implements mmap, but mapping
>>files to memory just so you can free it later seems a tad weasly. Plus the
> It's not files, it's anonymous mmap. It was made for this
If you say so. That's not the impression the man page gives.
>>memory mapped is usually nonswappable (I think) which would tend to chew
>>through available RAM pretty quickly...
> Where did that FUD come from? Anonymous mmap is swappable, just like brk.
Oh, please. The man page says nothing about swappability, and in a number
of places implies mmap locks physical memory.
And anonymous mmap looks to be a linux-only feature.
>>A better thing to do would be for someone to go ahead and fix the various
>>C libraries to hand free'd memory back, but it's been 30 years and
>>nobody's done it yet, so I probably shouldn't hold my breath.
> They've done it. The solution is anonymous mmap.
So, does anyone's C library actually use mmap for malloc'd memory? If not,
it's not that much good, especially since the feature you're looking at
(anonymous mmap) is tagged as linux only.
Dan
------------------------------
Date: Tue, 14 Sep 1999 16:08:54 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl / C Memory
Message-Id: <qquD3.13466$wW2.11607@news.rdc1.ct.home.com>
Kai Henningsen <kaih=7OmmKH$1w-B@khms.westfalen.de> wrote:
> dan@tuatha.sidhe.org (Dan Sugalski) wrote on 12.09.99 in <hzUC3.5897$wW2.8602@news.rdc1.ct.home.com>:
>> Kai Henningsen <kaih=7OhjZZ$mw-B@khms.westfalen.de> wrote:
>> > dan@tuatha.sidhe.org (Dan Sugalski) wrote on 04.09.99 in
>> > <sf_z3.148$lT.809@news.rdc1.ct.home.com>:
>>
>> >> Sure it does. Unfortunately just because perl frees memory doesn't mean
>> >> memory is returned back to the system. With very few exceptions (I think
>> >> MacOS and, under a few circumstances, VMS) any memory allocated to a
>> >> process by the OS stays with that process until it exits. This isn't a
>> >> perl thing--any program that mallocs memory will do it.
>>
>> > Linux with glibc2 can also, I gather, return free()d memory to the OS.
>>
>> > The way to do that is to not use brk(), but instead use mmap() to get the
>> > memory. Then you can munmap() it again.
>>
>> Well, OK, you can do that with any OS that implements mmap, but mapping
>> files to memory just so you can free it later seems a tad weasly.
> Why?
Because the purpose of mmap was to map disk files to memory. That's not
what we're doing.
>>Plus the
>> memory mapped is usually nonswappable (I think) which would tend to chew
>> through available RAM pretty quickly...
> Certainly not on in this case.
>> A better thing to do would be for someone to go ahead and fix the various
>> C libraries to hand free'd memory back, but it's been 30 years and
>> nobody's done it yet, so I probably shouldn't hold my breath.
> Because it's impossible in general if done with brk(). The number of
> processes that ever free significant amounts of memory at the upper bound
> is microscopic.
Who cares if the memory's not freed at the top of the heap? So you return
pages in the middle of your process' memory and have a gap. Big deal. If
you're returning memory, presumably you're actually keeping track of what
memory is in use. In which case holes are not a problem.
> It's called a heap because it doesn't behave like a stack.
So why treat it as one?
Dan
------------------------------
Date: Tue, 14 Sep 1999 15:57:07 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl and Threads
Message-Id: <nfuD3.13464$wW2.11607@news.rdc1.ct.home.com>
In comp.lang.perl.modules Kai Henningsen <kaih=7OmpB9sHw-B@khms.westfalen.de> wrote:
> dan@tuatha.sidhe.org (Dan Sugalski) wrote on 12.09.99 in <RnUC3.5807$wW2.8602@news.rdc1.ct.home.com>:
>> In comp.lang.perl.modules Kai Henningsen
>> > <kaih=7OhmO-w1w-B@khms.westfalen.de> wrote: dan@tuatha.sidhe.org (Dan
>> > Sugalski) wrote on 09.09.99 in <8dTB3.79$wW2.2668@news.rdc1.ct.home.com>:
>> > It's also not complete yet; pthreads really want some properties which
>> > aren't supported just yet, and there is discussion on how best to do it.
>> > (Including "if there's no good way to do it, it may be best to just forget
>> > about it - pthreads were a commitee invention anyway".)
>>
>> Hopefully saner heads will rule, since the way linux implements threads
>> now has a few very serious limitations. Taking up slots in the process
>> table is the biggest one,
> Actually, I agree with the people who claim that that's no limitation at
> all. It's a feature, not a bug.
I said limitation, not bug. While I'm all for quotas and other system
limitations on user processes, I'd be *real* hard-pressed to call this one
a feature.
>>and that puts a *huge* damper on some of the
>> neater things you can do with threads.
> Nope.
Yup. Start adding in threaded objects and you'll see the process table get
gobbled up. Heck, even if you throttle down processes to, say, 10 threads
a piece you just dropped the number of processes that can run by an order
of magnitude.
>>(Lots of the cool things involve
>> gobs of threads, and, well, how many folks have process tables large
>> enough to handle 250k threads? Can you even *have* that many under linux?)
> I think the change-#define-maximum on 2.1.12 is 4090, default 512. I also
> believe the reason for that number has disappeared in 2.3.<something>, so
> that one should be able to do a lot more. I haven't looked, though. (It's
> essentially an ix86 limitation, but the other architectures seem to have
> accepted the same limit.)
> But what on earth are you doing with *that* many threads?
Circuit simulation. Active game boards. Threaded objects in largish
programs. Communities of smart agents.
> Or do you mean "cool" as in "theoretical CS type solution, unusable under
> any realistic circumstances"? (Far too many of those around,
> unfortunately.)
Nope. Theoretical solutions require theoretical hardware, which
theoretically has no limitations. So the argument'd be moot... :-)
Dan
------------------------------
Date: Tue, 14 Sep 1999 15:28:00 GMT
From: kshagen@my-deja.com
Subject: perl ext .cgi with MS PWS
Message-Id: <7rlphi$ml9$1@nnrp1.deja.com>
I have several perls currently working with .pl ext. but when I change
the ext. to .cgi I receive "The page cannot be displayed". I have added
the mappings in the registry for both .pl and .cgi as per the Perl FAQ
documentation. Have I missed something or is there a problem with MS
Personal Web Server? I'm running NT 4.0, Perl 5.005_02 and MS PWS 4.0.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 16:41:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: perl ext .cgi with MS PWS
Message-Id: <MUuD3.10289$N77.791512@typ11.nn.bcandid.com>
In article <7rlphi$ml9$1@nnrp1.deja.com>, <kshagen@my-deja.com> wrote:
>I have several perls currently working with .pl ext. but when I change
>the ext. to .cgi I receive "The page cannot be displayed". I have added
>the mappings in the registry for both .pl and .cgi as per the Perl FAQ
>documentation. Have I missed something or is there a problem with MS
>Personal Web Server? I'm running NT 4.0, Perl 5.005_02 and MS PWS 4.0.
Wrong newsgroup. Go ask PWS people.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 14 Sep 1999 10:16:00 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Perl Y2k
Message-Id: <x3y3dwhfujj.fsf@tigre.matrox.com>
Li Kong <lkong@hns.com> writes:
> How can I get a 4-digital year using localtime()?
By reading the entry of localtime() in perlfunc.
--Ala
------------------------------
Date: Tue, 14 Sep 1999 16:41:04 GMT
From: makau@multimania.com
Subject: PLEASE HELP! - Symbolic References
Message-Id: <7rltqu$pki$1@nnrp1.deja.com>
The actual code is a lot more complicated but to summarize, here's what
I want to do :
---------------------------------
#!/usr/local/bin/perl -w
use strict;
my $key;
my %hash = (
hello => 'world',
perl => 'rOckz',
);
foreach $key (keys %hash) {
my ${$key} = $hash{$key};
};
print "The $hello $perl !";
---------------------------------
but the Perl interpreter prints out :
---------------------------------
Can't declare scalar deref in my at ./a.pl line 11, near "} ="
Global symbol "$hello" requires explicit package name at ./a.pl line 14.
Global symbol "$perl" requires explicit package name at ./a.pl line 14.
Execution of ./a.pl aborted due to compilation errors.
---------------------------------
Without the 'strict' subs, it works just fine.
But the problem is I do NOT want to remove it (since some warnings are
not displayed otherwise)!
And YES, I want to get $$key and not a hash.
I have my reason.
Is there a work-around, or can't Perl handle this when 'use strict' is
mentionned?
Please help...
I'm desperate!
Makau.
makau@multimania.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 14 Sep 1999 12:24:43 -0400
From: "RecruitSource" <examtesting@recruitsource.com>
Subject: Pre-release Beta Testers
Message-Id: <rtstdtjt1iv85@corp.supernews.com>
Our company, http://www.recruitsource.com, is looking for people to
beta-test an online technical testing system, which will soon be released to
the public. Specifically, we need people of various skill levels to take
one or more timed, multiple-choice exams, and to comment on/criticize the
exam as a whole, as well as on individual questions.
If you would like to partake, please reply and we will set you up with an
account.
Thanks for your help,
RecruitSource Tech Team
examtesting@recruitsource.com
------------------------------
Date: Tue, 14 Sep 1999 08:21:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Searching by date problem.
Message-Id: <MPG.124807bb4433a8d0989f61@nntp.hpl.hp.com>
In article <39tD3.145$UA3.10382@typhoon01.swbell.net> on Tue, 14 Sep
1999 14:42:07 GMT, Benjamin Franz <snowhare@long-lake.nihongo.org>
says...
...
> Except, possibly, in a life support monitoring machine in Japan
> that malfunctioned for 5 minutes starting at 9/9/99 09:09.
> Actual news item. Although possibly simple co-incidence.
'Possibly' indeed. 'Actual news item' ne 'fact' in any event -- or non-
event, in this case.
> --
> Benjamin Franz
> "People are not only stupider than you imagine, they
> are stupider than you _can_ imagine."
Is this self-referential? :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 14 Sep 1999 16:51:31 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Sweep several txt files into 1 big txt file.......
Message-Id: <n2vD3.10308$N77.793124@typ11.nn.bcandid.com>
In article <pagB3.759$1b7.10594@amsnews.chello.com>,
HPK <hanz@chello.nl> wrote:
>I'm looking for a cgi script that reads several txt files, and sweeps them
>into one big text file. I tried to program my own script, but it did not
>work.... Anyone where I can get this simple, but effective script?
It sounds like the program you want is called 'cat' in Unix. You can
write it in Perl like this:
#!/usr/bin/perl -p
(that's it. That's the whole program.)
This expands to (IIRC) while (<>){}continue{print}, which can just as
well be written as print while (<>);.
None of these are CGI scripts. You'll need to be more specific about
how arguments are being passed before anyone can really help you.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 14 Sep 1999 02:47:21 +0200
From: Benjamin Schweizer <SternSZ@gmx.de>
Subject: Re: syslog / linux
Message-Id: <m3lnaaiajq.fsf@anthrax.local.net>
+-->"Anthony Adams" <antoine@pacha.nl>:
| Benjamin Schweizer heeft geschreven in bericht ...
| >Hello,
| >
| >I´ve written a little daemon and I want to save messages (stdout) to the
| syslog
| >daemon. Is there a function in perl or is this done by the os?
| >
| Have you tried to use a | to the syslogd ?
This works, but it looks ugly. I want to do like the big guys ;-)
regards
-Benjamin
--
MICROSOFT (MSFT) announced today that the official
release date for the new operating system "Windows 2000"
will be delayed until the second quarter of 1901
------------------------------
Date: 14 Sep 1999 09:36:54 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: syslog / linux
Message-Id: <yln1uptpp5.fsf@windlord.stanford.edu>
Benjamin Schweizer <SternSZ@gmx.de> writes:
> I´ve written a little daemon and I want to save messages (stdout) to the
> syslog daemon. Is there a function in perl or is this done by the os?
There are a few different ways to do this.
One way is to write a little program, in either Perl or C, to read lines
from stdin and write them to syslog. I'd personally tend to use C, since
then you can use libc syslog(). Perl's current syslog implementation
leaves a bit to be desired.
Another way is to use a program that already does that, such as splogger
from the qmail distribution.
A third way is to modify your Perl program to write its messages to syslog
(using Sys::Syslog) rather than to stdout.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
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 793
*************************************