[17639] in Perl-Users-Digest
Perl-Users Digest, Issue: 5059 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 7 21:10:31 2000
Date: Thu, 7 Dec 2000 18:10:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976241418-v9-i5059@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 7 Dec 2000 Volume: 9 Number: 5059
Today's topics:
non-blocking safe pipe opens <sgp22@ipartner.net>
Perl and Visual Studio <ten@bluemoon.net>
Re: Perl SQL Array nobull@mail.com
Precedence, or other ??? <mds-resource@mediaone.net>
Re: Reading Data from STDIN nobull@mail.com
Re: Removing leading spaces <mjcarman@home.com>
Simple Perl Http Server <stuart@zerostate.co.uk>
Re: Simple Perl Http Server (Michael Fuhr)
Re: SMTP Sockets nobull@mail.com
Uploading file via CGI <g.soper@soundhouse.co.uk>
Re: Use PERL or Java? Which is faster? <raypendergraph@my-deja.com>
wxPerl ( wxWindows + Perl ) released (Mattia Barbon)
XML entities decoding shaikhr@yahoo.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 07 Dec 2000 23:26:21 GMT
From: Scott Wiersdorf <sgp22@ipartner.net>
Subject: non-blocking safe pipe opens
Message-Id: <3A301DBD.40D97804@ipartner.net>
Hello friends,
I posted last week but didn't ask the right question (and had buggy code
to post too, thx No-bull).
In the perlipc manpage there is a section called 'safe pipe opens' that
explains how to open a child to read from:
Here's a safe backtick or pipe open for read:
# add error processing as above
$pid = open(KID_TO_READ, "-|");
if ($pid) { # parent
while (<KID_TO_READ>) {
# do something interesting
}
close(KID_TO_READ) || warn "kid exited $?";
} else { # child
($EUID, $EGID) = ($UID, $GID); # suid only
exec($program, @options, @args)
|| die "can't exec program: $!";
# NOTREACHED
}
In the parent, we see <KID_TO_READ> in the while loop. This is a
blocking read.
I'd like to do something like the above but make it a non-blocking read
(I think) because I'll be forking off several dozen children at a time
and all should write to the same parent (that's another question I
have).
Is there anyone who has done this before who can point me in the right
direction? I know I can't mix the above with sys{read|open} stuff (at
least not without great caution).
I'm familiar with how 'select' works (for reading from multiple
filehandles) but am stumped on how to do it where the child writes back
to the parent.
Any help would be appreciated.
Scott
------------------------------
Date: Thu, 7 Dec 2000 20:11:15 -0500
From: "Thomas E Nowak Jr" <ten@bluemoon.net>
Subject: Perl and Visual Studio
Message-Id: <SzWX5.25$vL_3.6488378@news.randori.com>
I just downloaded ActivePerl-5.6.0.620 and already own Visual Studio
products Visual Basic 6 and Visual J 6. When I try to install Perl, I
receive:
If you have a development environment (e.g. Visual Studio) that you
wish to use with Perl, you should ensure that your environment (e.g.
%LIB% and %INCLUDE%) is set before installing.
Proceed? [y]
I do have Visual Studio, but I really dont know what this statement is
asking me. Any Ideas ? Please help.
------------------------------
Date: 07 Dec 2000 12:43:51 +0000
From: nobull@mail.com
Subject: Re: Perl SQL Array
Message-Id: <u9aea87660.fsf@wcl-l.bham.ac.uk>
"T Hawk" <support@REMOVEdotmatrix.net> writes:
> Im just getting into using a MySQL database for my scripts. I have run into
> a big problem though. I have a table with about 5 columns. I need to take
> the column named "names" and put all of the contents into an array. Can
> someone post an example of how this can be done?
my @an_array = @{ $dbi->selectcol_arrayref('select names from my_table') };
Note: you may want to do away with the step of copying the array.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 07 Dec 2000 19:09:57 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Precedence, or other ???
Message-Id: <3A3034E5.76106C82@mediaone.net>
my $i = 1;
my $j;
$j = ++$i*$i--;
print "j is now $j\n";
What is happening here?
Why is $j == 2 ???
How can I trace $i every step of the way?
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: 07 Dec 2000 18:23:09 +0000
From: nobull@mail.com
Subject: Re: Reading Data from STDIN
Message-Id: <u91yvk6qgi.fsf@wcl-l.bham.ac.uk>
Bill Nelson <william.c.nelson@gte.net> writes:
> Blame Internet browsers. I am doing a POST (or even a GET) to a particular
> port on the server. There is nothing in the data that indicates eof() -
> believe me, I check of eof(). The length of the data is, indeed, specified
> in the header of the packet, but you never know how big the header is going
> to be. Therefore I cannot key off of data in the header.
>
> The fun part is that I try specifying a length of the read that I know will
> be greater than anything the user could have inputted and the script sits
> there waiting for additional data from STDIN.
I missed the beginning of this, how did STDIN come to be connected to
the client end socket of a HTTP connection?
> Believe me, I wish this were as easy as you recommend.
When re-inventing the wheel it may be a good idea to draw on the
experiences of established wheelwrights.
Look at how this problem is addressed in the implementation of
LWP::Protocol::http::request().
BTW: What is your rationale for not using LWP in the first place?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 05 Dec 2000 16:52:13 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Removing leading spaces
Message-Id: <3A2D719D.C84AA92A@home.com>
Jonathan MILLEY wrote:
>
> I'm trying to find an effective way to trim leading spaces from
> a string.
>
As you might expect, this is a Frequently Asked Question. As such, it's
covered in the FAQ:
perldoc -q space
"How do I strip blank space from the beginning/end of a string?"
[snip]
If you look in the FAQ, you will find the answer you seek. (The reason
I'm not telling you isn't to be a pain in the *ss; I'm trying to
encourage you to utilize the resources you already have first.)
-mjc
------------------------------
Date: Fri, 8 Dec 2000 01:33:15 -0000
From: "Stuart Lowes" <stuart@zerostate.co.uk>
Subject: Simple Perl Http Server
Message-Id: <iPWX5.2414$tR1.44934@news2-win.server.ntlworld.com>
I am looking for guidance in how to write a simple http server for *small
part* of my university project. I need this simple server because I will be
adminstering apache and other ISP related facilties from the web, similar to
what webmin does.
Does anyone have any http server perl scripts (i really want to stick to
perl)?
Or can anyone point me in the right direction. I know there are perl httpd
servers out there and I obviously don't want to reinvent the wheel.
Thanks,
Stuart
------------------------------
Date: 7 Dec 2000 19:01:05 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Simple Perl Http Server
Message-Id: <90pfd1$cgv@flatland.dimensional.com>
"Stuart Lowes" <stuart@zerostate.co.uk> writes:
> I am looking for guidance in how to write a simple http server for *small
> part* of my university project. I need this simple server because I will be
> adminstering apache and other ISP related facilties from the web, similar to
> what webmin does.
>
> Does anyone have any http server perl scripts (i really want to stick to
> perl)?
> Or can anyone point me in the right direction. I know there are perl httpd
> servers out there and I obviously don't want to reinvent the wheel.
One way would be to use HTTP::Daemon (part of libwww).
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
------------------------------
Date: 07 Dec 2000 08:32:33 +0000
From: nobull@mail.com
Subject: Re: SMTP Sockets
Message-Id: <u9bsuo7eoh.fsf@wcl-l.bham.ac.uk>
mbutt@my-deja.com writes again despite the fact that I answered this
question already. I guess one or other of us has NNTP problems.
> Has anyone got some example code using Socket.pm
Does "anyone" have Perl installed?
perldoc Socket/"SYNOPSIS"
> Whick simply opens a socket on port 25 and sends out
> mail using SMTP commands.
Mail::Sender (from CPAN)
> (not IO::Socket or anything else).
I'm not suggesting you _use_ Mail::Sender, I'm suggesting you read the
source an example of using the old-style socket interface to
communicate with SMTP.
> Or just a simple example of opening a socket using perl.
Please make up your mind. Do you want a simple example or an example that
doesn't use IO::Socket? Using IO::Socket reduces several lines of
complex code to one statement.
If the examples in the "SYNOPSIS" section of the Socket.pm
documentation are too simple and Mail::Sender is too complex then try:
perldoc -f socket
Note the bit where it says "See the examples in..." and look where it
directs you.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 08 Dec 2000 00:45:02 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Uploading file via CGI
Message-Id: <4a296bcb8dg.soper@soundhouse.co.uk>
i'm using the following piece of code in my first attempt to upload a file
using CGI. While the file is created it is of zero length. Could somebody
point out my error?
Many thanks
Form:
<INPUT TYPE="file" NAME="upload_1" SIZE=60>
Script:
use CGI qw(:standard upload);
# Deal with uploaded pictures
$uploaded = upload('upload_1');
$upload_location = $news_location . "uploaded/" . $file;
open (UPLOAD, ">$upload_location") || die "can't open file: $!";
while ($upload_line = <$uploaded>) {
print UPLOAD $upload_line;
}
close UPLOAD;
--
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/
------------------------------
Date: Fri, 08 Dec 2000 01:24:38 GMT
From: Ray Pendergraph <raypendergraph@my-deja.com>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <90pd8j$f3i$1@nnrp1.deja.com>
Thanks for the heads up!
In article <90ouk2$c4l$1@bcarh8ab.ca.nortel.com>,
"John Doe" <johndoe@world.com> wrote:
> And on top of what you have mentionned, I've read on a few JavaTips,
from
> javaworld.com, that explain a few things you can do to improve
creation
> times of objects in Java. Basically, they can be resumed to creating
> components only when needed, and not all at start up!
>
> I don't remember the Tip #, but I suggest going through these Tips,
as you
> will most likely find something interesting or kill a myth about Java.
> http://www.javaworld.com/javaworld/javatips/jw-javatips.index.html
>
> Java's not that much slower, once you start learning about a few
tricks to
> improve the way you are using it!
>
> Cheers,
> JD
>
> Ray Pendergraph <raypendergraph@my-deja.com> wrote in message
> news:90oshm$107$1@nnrp1.deja.com...
> > Did I just hear right? Java is on par with C++? What VM are you
> > running? Please, i will pay you dearly for it. Object creation and
> > overloaded calling are several hundred ms slower in java, not to
> > mention gc.
> >
> > (for example)It takes me about 90ms to create object "x" on solaris
> > Ultra60 and about 350 to 400 ms to create a java x (we have done
some
> > bench testing).
> >
> > Java is rather a slow beast (even with massive object reuse), but
you
> > gotta love it. However ther are several options that will make java
run
> > faster including other vms and native compiling (for applications).
The
> > latter really bloats your jar files.
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 7 Dec 2000 20:19:11 GMT
From: mbarbon@dsi.unive.it (Mattia Barbon)
Subject: wxPerl ( wxWindows + Perl ) released
Message-Id: <9003D057Crbootliberoit@159.149.167.224>
Hello,
I've released the first version of wxPerl, the Perl bindings
to wxWindows; you may download them from
http://sourceforge.net/projects/wxperl
The homepage is
http://wxperl.sourceforge.net/
wxWindows is a free and cross platform (Windows/Motif/GTK/Mac)
C++ GUI toolkit, with native look and feel.
( visit http://www.wxwindows.org/ for more detailed informations ).
If you want to experiment with wxPerl please note that
1) this is the first public release
2) it lacks a good documentation
(refer to the site above for a short manual and a little
tutorial, but you will also need the full wxWindows
documentation: dowload it from http://www.wxwindows.org/ )
3) there aren't binary releases (but compiling it should be
simple, at least for tested platforms)
wxGTK/Linux/gcc 2.95.2/perl 5.004/5.5 and
wxMSW/Win95,Win2k/VC++ 5/ActivePerl build 616
based on Perl 5.6.0
( of course you will need wxWindows to build wxPerl )
There is a mailing list: go to
http://wxperl.sourceforge.net/ and follow the link for ML
Hope you like it
Mattia
------------------------------
Date: Thu, 07 Dec 2000 23:16:30 GMT
From: shaikhr@yahoo.com
Subject: XML entities decoding
Message-Id: <90p5oa$97n$1@nnrp1.deja.com>
For getting HTML character references, there is a module
HTML::entitites that can encode or decode character refernces, e.g >
means ">" or ' means an apostrophe. You simply use the encode or
decode function of the module.
Is there any similar module out there that does encoding and decoding
of character refernces for XML?
Thanks.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5059
**************************************