[19112] in Perl-Users-Digest
Perl-Users Digest, Issue: 1307 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 15 06:06:26 2001
Date: Sun, 15 Jul 2001 03:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <995191510-v10-i1307@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 15 Jul 2001 Volume: 10 Number: 1307
Today's topics:
Re: "family tree" generator (Martin Vorlaender)
Re: Can I <!--include files ??? <andras@mortgagestats.com>
Re: Can I <!--include files ??? <godzilla@stomp.stomp.tokyo>
Re: Can I <!--include files ??? <dcs@ntlworld.com>
Re: Can I <!--include files ??? <dcs@ntlworld.com>
Re: Can it be done without DBI/DBD??? (Mark Deibert)
Re: Can it be done without DBI/DBD??? <pne-news-20010715@newton.digitalspace.net>
Re: Can it be done without DBI/DBD??? (isterin)
Re: Can it be done without DBI/DBD??? (isterin)
Re: Causing a slow page delivery (on purpose) (Scott Porter)
Re: Causing a slow page delivery (on purpose) <pne-news-20010715@newton.digitalspace.net>
Re: Causing a slow page delivery (on purpose) (Scott Porter)
chomp (derelixir)
FAQ: How do I debug my Perl programs? <faq@denver.pm.org>
FAQ: Is there a Perl shell? <faq@denver.pm.org>
Re: FAQ: Is there a Perl shell? (fvw)
Re: HELP! - Input text field problems! <firma@steinhaug.com>
Re: how many bytes to read from socket? <goldbb2@earthlink.net>
Re: how many bytes to read from socket? <skilchen@swissonline.ch>
Re: how many bytes to read from socket? <uri@sysarch.com>
Re: How popular is Python, anyway? (was: Long Live Pyth <not-a-real-address@usa.net>
Re: How to timeout a socket recv under win32? <goldbb2@earthlink.net>
Re: LOOKING FOR PERL JOBS (David H. Adler)
LWP::Protocol::http - what are the hidden Windows requi (Mike)
Re: pass data from .exe to .perl <goldbb2@earthlink.net>
Re: perl debugger <andras@mortgagestats.com>
Re: perl debugger <AHALL5@nc.rr.com>
Re: perl debugger (Chad)
Re: Perl/Sendmail not sending mail? (el)
Re: Recommendation for a book covering MySQL and Perl <emdee@DEMUNGEcwcom.net>
Re: Regex question <goldbb2@earthlink.net>
Re: Using Array and while() loops <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 15 Jul 2001 10:28:56 +0200
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: "family tree" generator
Message-Id: <3b515448.524144494f47414741@radiogaga.harz.de>
Kenneth Bruyninckx (kenneth@akerne-orchids.com) wrote:
> I'm looking for a script that given a set of data can "draw" (display the
> names with interconnecting lines) a tree structure.
Have a look at the Leon Brocard's GraphViz module on CPAN (and the
graphing package of the same name on http://www.graphviz.org).
cu,
Martin
--
So long, and thanks | Martin Vorlaender | VMS & WNT programmer
for all the books... | work: mv@pdv-systeme.de
In Memoriam Douglas Adams | http://www.pdv-systeme.de/users/martinv/
1952-2001 | home: martin@radiogaga.harz.de
------------------------------
Date: Sat, 14 Jul 2001 21:04:37 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Can I <!--include files ???
Message-Id: <3B50EC25.1B62FF50@mortgagestats.com>
Terry wrote:
> Hi,
>
> All of my 'standard' webpages are *.shtml using SSI. This is great in that I
> can have a standard template file for header, navigation menu and footer of
> my pages by using the
>
> <!--include file="template.html"-->
> directive.
> I wanted to use the same templates for my cgi pages. Is there any way of
> doing this?
>
> TIA
>
> Terry
Probably yes, but this has nothing to do with Perl and everything to do with
your server and the way it is configured. For Apache servers, check out these
links:
http://httpd.apache.org/docs/howto/ssi.html
http://help.mindspring.com/docs/008/wh_server_side_includes/server_side_includes.php3
If you are on another server, try to look up its documentation on the web.
Despite what other posters have suggested, I doubt that the CGI newsgroup or
CPAN will be of much help.
------------------------------
Date: Sat, 14 Jul 2001 19:11:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Can I <!--include files ???
Message-Id: <3B50FBE8.E9F4A1E9@stomp.stomp.tokyo>
Terry wrote:
> All of my 'standard' webpages are *.shtml using SSI.
> This is great in that I can have a standard template
> file for header, navigation menu and footer of
> my pages by using the...
This is untrue. You cannot include one file and
create both a header and a footer with whatever
included between those two. A Server Side Include
call opens and prints an entire file. It is quite
impossible for you to split this SSI called file
and insert other html, within, much less some
navigation menu tossed in to boot.
> <!--include file="template.html"-->
> directive.
> I wanted to use the same templates for my cgi pages.
You are now indicating multiple templates where previously
a single template is indicated. Are you confused?
> Is there any way of doing this?
Read about and research open () and print () functions.
What you ask is quite easy.
Godzilla!
------------------------------
Date: Sun, 15 Jul 2001 10:33:42 +0100
From: "Terry" <dcs@ntlworld.com>
Subject: Re: Can I <!--include files ???
Message-Id: <Fqd47.42558$B56.9042961@news2-win.server.ntlworld.com>
Hi Godzilla!
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3B50FBE8.E9F4A1E9@stomp.stomp.tokyo...
> Terry wrote:
>
>
> > All of my 'standard' webpages are *.shtml using SSI.
> > This is great in that I can have a standard template
> > file for header, navigation menu and footer of
> > my pages by using the...
>
> This is untrue. You cannot include one file and
> create both a header and a footer with whatever
> included between those two. A Server Side Include
> call opens and prints an entire file. It is quite
> impossible for you to split this SSI called file
> and insert other html, within, much less some
> navigation menu tossed in to boot.
>
I don't state that I am using *one* template file.
>
> > <!--include file="template.html"-->
> > directive.
>
> > I wanted to use the same templates for my cgi pages.
>
> You are now indicating multiple templates where previously
> a single template is indicated. Are you confused?
>
Are you ¿
If you have nothing better to do than pick up on totally unimportant aspects
of the post, then you would be better doing nothing !!!
>
> > Is there any way of doing this?
>
>
> Read about and research open () and print () functions.
>
> What you ask is quite easy.
>
>
> Godzilla!
------------------------------
Date: Sun, 15 Jul 2001 10:34:37 +0100
From: "Terry" <dcs@ntlworld.com>
Subject: Re: Can I <!--include files ???
Message-Id: <wrd47.42559$B56.9043628@news2-win.server.ntlworld.com>
"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
news:3B50EC25.1B62FF50@mortgagestats.com...
>
>
> Terry wrote:
>
> > Hi,
> >
> > All of my 'standard' webpages are *.shtml using SSI. This is great in
that I
> > can have a standard template file for header, navigation menu and footer
of
> > my pages by using the
> >
> > <!--include file="template.html"-->
> > directive.
> > I wanted to use the same templates for my cgi pages. Is there any way of
> > doing this?
> >
> > TIA
> >
> > Terry
>
> Probably yes, but this has nothing to do with Perl and everything to do
with
> your server and the way it is configured. For Apache servers, check out
these
> links:
>
> http://httpd.apache.org/docs/howto/ssi.html
>
http://help.mindspring.com/docs/008/wh_server_side_includes/server_side_incl
udes.php3
>
> If you are on another server, try to look up its documentation on the web.
>
> Despite what other posters have suggested, I doubt that the CGI newsgroup
or
> CPAN will be of much help.
Thanks Andras, I'll check them out :)
Terry
------------------------------
Date: 14 Jul 2001 17:01:42 -0700
From: area31@mail.com (Mark Deibert)
Subject: Re: Can it be done without DBI/DBD???
Message-Id: <20f405bf.0107141601.32c576ff@posting.google.com>
Thanks a lot for your help guys. Much appreciated.
The problems that I've been having with ActiveState Perl are problems
on my local machine. I have AS Perl installed on this machine. When I
try to use the PPM to fetch and install DBI, I get some crazy error
message something like 'no package exists for version blah, blah,
blether' Aparently no DBI for my version of AS Perl exists. My version
is the one that supports multi-threading. Should I change versions of
Perl?
After struggling for a day or two trying to get it to work on my local
machine, I decided to try running scripts on my ISP ( iNNERHOST.com ).
I then learned that I'd have to pay the $25 fee to get DBI installed.
If I can get DBI on my local machine, then all will be well in the
universe.
Thanks again guys :-)
------------------------------
Date: Sun, 15 Jul 2001 08:03:39 +0200
From: Philip Newton <pne-news-20010715@newton.digitalspace.net>
Subject: Re: Can it be done without DBI/DBD???
Message-Id: <6fc2lt8901092l14foher1l2jsupjk45ve@4ax.com>
On 14 Jul 2001 17:01:42 -0700, area31@mail.com (Mark Deibert) wrote:
> I have AS Perl installed on this machine. When I try to use the PPM
> to fetch and install DBI, I get some crazy error message something
> like 'no package exists for version blah, blah, blether' Aparently
> no DBI for my version of AS Perl exists.
Is this maybe caused by an improper command line? I would expect
something like 'ppm install DBI' to work. Not DBI.pm or DBI-1.14.tar.gz
or something like that, for example.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 14 Jul 2001 23:42:44 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Can it be done without DBI/DBD???
Message-Id: <db67a7f3.0107142242.6a7db0c6@posting.google.com>
Then install the latest perl from actistate 5.6 and then install the
modules.
Or install on the server in a private dir by using...
perl Makefile.PL PREFIX=/private/dir ## Don't forget to change the
/private/dir :-)
Also why not switch ISP. I've been with too many and have never heard
of first of all not having the DBI module already installed (they must
be technologically behind:-), and second charging for installing a
module.
Ilya
area31@mail.com (Mark Deibert) wrote in message
news:<20f405bf.0107141601.32c576ff@posting.google.com>...
> Thanks a lot for your help guys. Much appreciated.
>
> The problems that I've been having with ActiveState Perl are problems
> on my local machine. I have AS Perl installed on this machine. When I
> try to use the PPM to fetch and install DBI, I get some crazy error
> message something like 'no package exists for version blah, blah,
> blether' Aparently no DBI for my version of AS Perl exists. My version
> is the one that supports multi-threading. Should I change versions of
> Perl?
>
> After struggling for a day or two trying to get it to work on my local
> machine, I decided to try running scripts on my ISP ( iNNERHOST.com ).
> I then learned that I'd have to pay the $25 fee to get DBI installed.
> If I can get DBI on my local machine, then all will be well in the
> universe.
>
> Thanks again guys :-)
------------------------------
Date: 14 Jul 2001 23:44:27 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Can it be done without DBI/DBD???
Message-Id: <db67a7f3.0107142244.4e0ff5ce@posting.google.com>
David Coppit <newspost@coppit.org> wrote in message news:<3B4F68D8.9070801@coppit.org>...
> Mark Deibert wrote:
>
> > I've been having all kinds of problems installing DBI using
> > ActiveState's PPM. I just can't get to work. My ISP says I have to pay
> > $25.00 for them to install the -free- DBI module. Isn't that nice of (
> > iNNERHOST.com ) to charge -one- user (me) so -all- users can have
> > access to a module!
> >
> > Can you access databases (Access, Oracle, SQL server, etc.) without
> > using the DBI module? How hard will this be?
>
>
> Either pay the $$ or install the module yourself in a private
> subdirectory and modify your PERL5LIB environment variable. My rule of
> thumb is that my time is worth $15, and pay anyone who can do the work
Hmmm and I always thought Virginia had good programming rates. In
Michigan you can earn $15 in McDonald's:-)
Ilya
> for less. In this case, I suspect that it will take you about an hour to
> install the module yourself if you've never done a private module
> installation.
>
> Search groups.google.com for "comp.lang.perl.* private lib module
> install" for info on how to do a private module install.
>
> David
------------------------------
Date: Sat, 14 Jul 2001 23:42:29 GMT
From: scott@nospamthankx.javascript-games.org (Scott Porter)
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <3b50d77f.100924078@news.freeserve.co.uk>
On Thu, 12 Jul 2001 18:33:44 -0700, "$Bill Luebkert" <dbe@wgn.net> wrote:
[...]
>Have you tried forcing your output buffer to overflow with something like:
>
> print ' ' x 4096;
>
Aha! I altered the script to send out 256 bytes immediately after the header info as
so:
#!/usr/bin/perl -w
use strict;
$| = 1;
print "Content-Length: 200000\n";
print "Connection: open\n";
print "Content-type: text/plain\n\n";
print " " x 256;
for( 1..5 ) {
print "x\n";
sleep 1;
}
This solved the problem, as it seems the browsers will always buffer (?) bytes before
displaying anything at all. I also found if I changed the content length to something
tiny (eg 2), then the browser would close the connection after the first x, although
the script was still active, so setting it to a really high number is the answer!
Thanks to all who helped...
Scott
------------------------------
Date: Sun, 15 Jul 2001 08:01:53 +0200
From: Philip Newton <pne-news-20010715@newton.digitalspace.net>
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <9bc2lto4c1md65mb65spdj2c7cda73mk8t@4ax.com>
On Sat, 14 Jul 2001 23:42:29 GMT,
scott@nospamthankx.javascript-games.org (Scott Porter) wrote:
> I also found if I changed the content length to something
> tiny (eg 2), then the browser would close the connection
> after the first x, although the script was still active,
Makes sense to me. After all, you told the browser only to expect 2
bytes. It's not its fault if you lied to it and the script is really
still active and generating output.
> so setting it to a really high number is the answer!
I would imagine it would be best to set the 'Content-length' header to
the number of bytes you are going to output.
If you cannot know in advance the number of bytes you are going to
print, you should leave out the Content-length header AIUI.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 15 Jul 2001 09:11:04 GMT
From: scott@nospamthankx.javascript-games.org (Scott Porter)
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <3b515d01.135102187@news.freeserve.co.uk>
On Sun, 15 Jul 2001 08:01:53 +0200, Philip Newton
<pne-news-20010715@newton.digitalspace.net> wrote:
>On Sat, 14 Jul 2001 23:42:29 GMT,
>scott@nospamthankx.javascript-games.org (Scott Porter) wrote:
>
>> I also found if I changed the content length to something
>> tiny (eg 2), then the browser would close the connection
>> after the first x, although the script was still active,
>
>Makes sense to me. After all, you told the browser only to expect 2
>bytes. It's not its fault if you lied to it and the script is really
>still active and generating output.
Well that's not always the case, since (as I mentioned earlier in the thread) I could
send down any amount of information no matter what I'd set the content length to in
the header IF I didn't send down the 256 bytes to flush the buffer first. Lynx would
just report a negative number of bytes remaining. So it would appear that "lying" to
the browser sometimes does work.
>> so setting it to a really high number is the answer!
>
>I would imagine it would be best to set the 'Content-length' header to
>the number of bytes you are going to output.
>
>If you cannot know in advance the number of bytes you are going to
>print, you should leave out the Content-length header AIUI.
I don't think you fully understand the purpose of the script. Thanks for your input
though, it's been most helpful :-)
------------------------------
Date: 14 Jul 2001 22:16:34 -0700
From: derelixir@my-deja.com (derelixir)
Subject: chomp
Message-Id: <fd50a1dc.0107142116.7aac8574@posting.google.com>
Hello...
I have a text file which contains something like this :
A Famosa Golf Resort,MEL,MS,13,31,22,87,14,30,20,87,15,29,21,87,16,29,22,87,17,28,22,87,18,29,21,87
A Famosa Water World,MEL,MS,13,31,22,87,14,30,21,87,15,29,19,87,16,29,22,87,17,28,22,87,18,29,21,87
Aachen,,DL,13,16,12,69,14,20,12,87,15,17,11,87,16,20,11,87,17,19,10,87,18,17,12,87
and I have a code to read the text file that looks like this:
$/="\n";
open (MY_FILE, "<$MY_FILE") || die "cannot read file $MY_FILE\n";
# Convert remaining CSV forecast data:
while (<MY_FILE>) {
chomp;
( $city, $state, $country, @data ) = split(/,/);
$location = "$city,$state,$country";
print "$data[23]\n"; ## just to check the value
....
....
but the chomp doesnt chomp the new line. The
'print "$data[23]\n";'
will print :
87
A Famosa Water World
and not only the value of '87' which is the last element in that
particular line..
Can someone help me with this problem?
Thank you.
Regards
------------------------------
Date: Sun, 15 Jul 2001 06:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I debug my Perl programs?
Message-Id: <xza47.153$T3.211363840@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I debug my Perl programs?
Have you tried "use warnings" or used "-w"? They enable warnings to
detect dubious practices.
Have you tried "use strict"? It prevents you from using symbolic
references, makes you predeclare any subroutines that you call as bare
words, and (probably most importantly) forces you to predeclare your
variables with "my", "our", or "use vars".
Did you check the return values of each and every system call? The
operating system (and thus Perl) tells you whether they worked, and if
not why.
open(FH, "> /etc/cantwrite")
or die "Couldn't write to /etc/cantwrite: $!\n";
Did you read the perltrap manpage? It's full of gotchas for old and new
Perl programmers and even has sections for those of you who are
upgrading from languages like *awk* and *C*.
Have you tried the Perl debugger, described in the perldebug manpage?
You can step through your program and see what it's doing and thus work
out why what it's doing isn't what it should be doing.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
03.04
--
This space intentionally left blank
------------------------------
Date: Sun, 15 Jul 2001 00:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Is there a Perl shell?
Message-Id: <1i547.148$T3.190343168@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
Is there a Perl shell?
In general, no. The Shell.pm module (distributed with Perl) makes Perl
try commands which aren't part of the Perl language as shell commands.
perlsh from the source distribution is simplistic and uninteresting, but
may still be what you want.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
03.03
--
This space intentionally left blank
------------------------------
Date: Sun, 15 Jul 2001 00:45:10 GMT
From: fvw+usenet@var.cx (fvw)
Subject: Re: FAQ: Is there a Perl shell?
Message-Id: <995157824DLA.fvw@var.cx>
faq@denver.pm.org (PerlFAQ Server) wrote:
> Is there a Perl shell?
>
> In general, no. The Shell.pm module (distributed with Perl) makes Perl
> try commands which aren't part of the Perl language as shell commands.
> perlsh from the source distribution is simplistic and uninteresting, but
> may still be what you want.
Am I missing something here, or do they mean http://www.focusresearch.com/gregor/psh/
with a perl shell? If nobody objects, I'll mail the faq maintainer
about it...
--
Frank v Waveren Fingerprint: 0EDB 8787
fvw@[var.cx|dse.nl|stack.nl|chello.nl] ICQ#10074100 09B9 6EF5 6425 B855
Public key: http://www.var.cx/pubkey/fvw@var.cx-gpg 7179 3036 E136 B85D
------------------------------
Date: Sun, 15 Jul 2001 09:03:32 GMT
From: "Steinhaugs Webdesign" <firma@steinhaug.com>
Subject: Re: HELP! - Input text field problems!
Message-Id: <E%c47.8938$qR5.1012247@news01.chello.no>
I found the sollution,
Here is the snipplet with the working sollution :
open (PROGRESSFILE, "data/message.log");
@messageRAW = <PROGRESSFILE>;
close (PROGRESSFILE);
$messagetest = "";
foreach $line (@messageRAW) {
chomp($line); # Remove \n \r \t and other linefeeds
$messagetest .= "$line\n";
}
"$messagetest" has the same input as the textfield would post.
Kim Steinhaug
kim@steinhaug.com
www.steinhaug.com
------------------------------
Date: Sat, 14 Jul 2001 20:15:38 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how many bytes to read from socket?
Message-Id: <3B50E0AA.9DD677@earthlink.net>
Uri Guttman wrote:
>
> >>>>> "MM" == Mark McKay <kitfox@kitfox.com> writes:
[snip]
> MM> So, would you know how to determine the number of bytes a socket
> MM> has available for reading?
>
> that is a useless piece of information you are requesting. when you
> read from socket, you must handle buffering and parsing on your own.
> in general you read as much as you can handle each time. the read call
> will tell you how much you have read (if any).
Yes, but suppose that you want to wait until you have one complete
record available for readin before processing, and *don't* want to
buffer yourself? For instance:
for( ; ; ) {
while( my ($name, $sock) = each %peers ) {
if( bytesready( $sock ) >= $PACKETSIZE ) {
local $/ = \$PACKETSIZE;
$gui->show_packet( $name, scalar <$sock> );
}
}
if( $gui->check_for_data() ) {
my $packet = $gui->make_send_packet()
for my $sock ( values %peers ) {
print $sock $packet;
}
}
}
Yes, this is contrieved, but similar to what one might expect a chat
client to do.
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Sun, 15 Jul 2001 02:11:19 +0200
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: how many bytes to read from socket?
Message-Id: <9iqnln$kbvjt$1@ID-13368.news.dfncis.de>
"Mark McKay" <kitfox@kitfox.com> schrieb im Newsbeitrag
news:3B506C27.1FC622B1@kitfox.com...
> I'm trying to create a simple chat server application. I have it mostly
> running, and am using sysread() and syswrite() calls on my sockets to
> keep everything nonblocking. However, sysread() requires an integer
> input specifing how many characters to read. How would I tell this? Is
> there some function that says how many characters in a socket are
> waiting to be read (if any)?
>
> I'm using the IO::Socket and IO::Select to create and manage several
> connections.
>
If select() tells you that there are data available to read from a socket,
the next sysread() call will not block even if there are fewer bytes
available to read than the value you passed as the LENGTH argument to
sysread().
The same thing is not true if you want to make sure that writes to the
socket won't block. In this case you have to put the socket in non-blocking
mode.
In both cases you have to handle the buffering of the data yourself. E.g.
you have to deal with sysreads() that do not return as many bytes as you
expected, and with syswrites() that don't send as many bytes as expected.
------------------------------
Date: Sun, 15 Jul 2001 00:24:43 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how many bytes to read from socket?
Message-Id: <x7hewfvy2b.fsf@home.sysarch.com>
>>>>> "BG" == Benjamin Goldberg <goldbb2@earthlink.net> writes:
BG> Yes, but suppose that you want to wait until you have one complete
BG> record available for readin before processing, and *don't* want to
BG> buffer yourself? For instance:
that is called polling and it is a very poor idea.
BG> for( ; ; ) {
that sucks all the cpu you got. you have no blocking calls in the loop.
BG> while( my ($name, $sock) = each %peers ) {
BG> if( bytesready( $sock ) >= $PACKETSIZE ) {
and if you see 1 byte ready but want 2, you loop forever.
BG> local $/ = \$PACKETSIZE;
BG> $gui->show_packet( $name, scalar <$sock> );
BG> }
BG> }
BG> if( $gui->check_for_data() ) {
BG> my $packet = $gui->make_send_packet()
BG> for my $sock ( values %peers ) {
BG> print $sock $packet;
BG> }
BG> }
BG> }
BG> Yes, this is contrieved, but similar to what one might expect a chat
BG> client to do.
being a chat client is no different than any other client. you don't
poll sockets unless you canburn the cpu all you want. some embedded
systems can do that but no general purpose one should have to.
and teaching the poor kid (this has to be a student project, no one
build new chat servers), a poor technique like polling when he should
learn proper client server design does him a disservice.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: 15 Jul 2001 08:18:27 GMT
From: those who know me have no need of my name <not-a-real-address@usa.net>
Subject: Re: How popular is Python, anyway? (was: Long Live Python!)
Message-Id: <9irjkj31h16@enews1.newsguy.com>
<slrn9kpv3p.ooh.philh@comuno.freeserve.co.uk> divulged:
>On 11 Jul 2001 21:20:02 GMT, Gergo Barany <gergo.barany@gmx.net> wrote:
>>phil hunt <philh@comuno.freeserve.co.uk> wrote:
>>> [snip flamebait crap]
>>
>>If anyone is going to to respond to this thread, *please* take
>>comp.lang.c out of the Newsgroups: list. We don't do advocacy here.
>>Followups set.
>
>My post was an entirely objective statistical summary, and contained
>no subjective or opinion-based data at all.
whether or not that is true, the subject isn't appropriate for most of the
groups to which it was posted.
--
okay, have a sig then
------------------------------
Date: Sat, 14 Jul 2001 21:22:55 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to timeout a socket recv under win32?
Message-Id: <3B50F06F.EFDB332E@earthlink.net>
Horace wrote:
>
> Hi everyone,
> I'm new to perl and sorry if this question has been asked before,
> that's how to timeout a socket recv under win32 environmnet? I know
> that under unix, I can use "alarm", but how about win32?
> I saw some people suggested using "vec" and "select" to implement
> the timeout, but I don't know how.
> Please help and thanks in advance!
IO::Select is probably the easiest way to go.
use IO::Select;
my $select = IO::Select->new( \*SOCKET );
...
if( $select->can_read( $timeout ) ) {
my $sender = recv SOCKET, my $packet, 256, 0
or die "recv failed: $!";
print "Got ", length($packet), " bytes from ";
print gethostbyaddr( (sockaddr $sender)[1] ), "\n";
print unpack("H*",$packet), "\n";
}
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: 15 Jul 2001 01:16:12 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: LOOKING FOR PERL JOBS
Message-Id: <slrn9l1rms.p0u.dha@panix2.panix.com>
In article <120720011641194147%cometlinear@yahoo.com>, dot-comet wrote:
> I am looking for intermediate-level PERL jobs. I am willing to work
> inexpensively in exchange for experience.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
http://jobs.perl.org may be of more use to you
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Last year in Oregon, Summer fell on a *tuesday*. That was it. One
day. Big shiny thing in the sky. Some people thought it was a UFO."
- Randal Schwartz in comp.lang.perl.misc
------------------------------
Date: 14 Jul 2001 21:39:54 -0700
From: michael_of_neb@yahoo.com (Mike)
Subject: LWP::Protocol::http - what are the hidden Windows requirements ?
Message-Id: <5a10590e.0107142039.6eb22ec9@posting.google.com>
I've already openly asked some questions about setting up Openssl.
The answers seem rather incomplete, especially considering that
there is so much demand for secured transactions of a standard
kind on the net, and Perl being the language of choice for so
much net programming, you would think there would either be a
huge standard package or a booming business in helping people
just like me.
Either way, I haven't found it - yet.
Now I have a more urgent question.
In the process of attempting to install the openssl systems,
so that I can use perl to open a rather simple httpS page
and enter some rather simple infformation into its form...
I have crashed my entire perl engine. Bummer.
I have traced the problem down to the line:
eval "require $ic";
where this translates to:
require LWP::Protocol::http
which immediately gives Windows the system Perl box error
with the blue top border and the red circle with the white x in it,
and the buttons on the right titled close, debug and details.
It says,
"This program has performed an illegal operation
and will be shut down.
If the problem persists, contact the program
vendor."
This takes place now every time I am attempting to do standard
WWW processing using perl WWW classes.
I have no clue how to use these Debug and Details>> buttons.
The answers coming back seem utterly useless to me.
I believe that I have accidentally destroyed something important
by attempting to build the Openssl stuff, and the consequence is
an error message that is undecipherable.
There have been no apparent changes to anything in the /bin and /lib
parts of the Perl directory. If so, of course, I would go back to a
previous version, and be done with it.
Where does one begin to look among the things that perl uses
among the rest of the system dlls and exes and the like
for such an error condition ?
The facts seem to indicate that the erroris hidden among some vital
standard components that have somehow become changed in the process
of attempting to install openssl in rder to install SSLeay in order
to ... you know.
I'm at my wits end.
Please help.
Sincerely,
Mike
------------------------------
Date: Sat, 14 Jul 2001 20:56:28 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: pass data from .exe to .perl
Message-Id: <3B50EA3C.A730B323@earthlink.net>
dom wrote:
>
> Hi,
>
> Is there anyway pass a block of data from .exe to .perl without using
> stdio or write to file?
The commandline is one way :) But since command.com and variants do
funky things with the arguments (joining them all and then splitting on
whitespace), you have to escape the data that you want to give --
turning it into a hex string is probably simplest.
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Sat, 14 Jul 2001 21:39:03 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: perl debugger
Message-Id: <3B50F437.4FE9B258@mortgagestats.com>
Chad Yoshikawa wrote:
> Is there an easy-to-setup perl debugger on windows? I had heard there
> is one for windows before but I also heard that it's very hard to
> configure.
>
> I found programming in perl is hard since It don't have a nice
> debugger. What do you guys think?
>
> Thanks.
Of course you can run Perl in debug mode by using the -d switch, but you
knew that, right?
Other than that, searching Google for "Perl debugger" gave me over 10,000
hits. See if one of those suits you.
------------------------------
Date: Sun, 15 Jul 2001 03:29:56 GMT
From: "Antoine Hall" <AHALL5@nc.rr.com>
Subject: Re: perl debugger
Message-Id: <U6847.146691$Md.34079223@typhoon.southeast.rr.com>
Why don't you just run the your script from the command line using the -c
switch. It will tell you if your program has any errors or anything.
perl -c scriptname
==
'Toine
"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
news:3B50F437.4FE9B258@mortgagestats.com...
>
>
> Chad Yoshikawa wrote:
>
> > Is there an easy-to-setup perl debugger on windows? I had heard there
> > is one for windows before but I also heard that it's very hard to
> > configure.
> >
> > I found programming in perl is hard since It don't have a nice
> > debugger. What do you guys think?
> >
> > Thanks.
>
> Of course you can run Perl in debug mode by using the -d switch, but you
> knew that, right?
>
> Other than that, searching Google for "Perl debugger" gave me over 10,000
> hits. See if one of those suits you.
>
>
------------------------------
Date: Sun, 15 Jul 2001 04:59:39 GMT
From: m_010@yahoo.com (Chad)
Subject: Re: perl debugger
Message-Id: <3b522314.292420@enews.newsguy.com>
Thanks all the help, I don't know any perl stuff except some perl
syntax.
On Sun, 15 Jul 2001 03:29:56 GMT, "Antoine Hall" <AHALL5@nc.rr.com>
wrote:
>Why don't you just run the your script from the command line using the -c
>switch. It will tell you if your program has any errors or anything.
>
>perl -c scriptname
>
>
>==
>'Toine
>
>
>"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
>news:3B50F437.4FE9B258@mortgagestats.com...
>>
>>
>> Chad Yoshikawa wrote:
>>
>> > Is there an easy-to-setup perl debugger on windows? I had heard there
>> > is one for windows before but I also heard that it's very hard to
>> > configure.
>> >
>> > I found programming in perl is hard since It don't have a nice
>> > debugger. What do you guys think?
>> >
>> > Thanks.
>>
>> Of course you can run Perl in debug mode by using the -d switch, but you
>> knew that, right?
>>
>> Other than that, searching Google for "Perl debugger" gave me over 10,000
>> hits. See if one of those suits you.
>>
>>
>
------------------------------
Date: 15 Jul 2001 02:25:56 -0700
From: el@wilmington.net (el)
Subject: Re: Perl/Sendmail not sending mail?
Message-Id: <58929d2c.0107150125.6ab4097f@posting.google.com>
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote in message news:<slrn9kofq3.av5.rgarciasuarez@rafael.kazibao.net>...
> You're not using "strict" ? and -w ? You should. This can point you
> basic errors that are otherwise a pain to detect.
>
> } open(EMAIL, "|$mailprog $email") || &error("Sendmail error: $!");
>
> I hope that you're sure that's $email here.
>
> Have you read perldoc -q "send mail" ?
> Have you checked the mail queue and the maillogs ? The problem may come
> from the sendmail configuration at the host you're using. Is it the
> recommended configuration ?
> Have you tried to use a Mail module and to connect to a SMTP server,
> other than your host ?
// above post snipped to preserve bandwidth //
I am using -w (no errors) but not strict (the errors read that I need
"explicit package name(s)" and I haven't had time to study C19 of the
PERL Black Book yet). $email does exist and is verified in my
returned html. My host has not installed many Modules - I've tried to
use the various Mail associated ones but haven't had any success there
either. I (to my knowledge) do not have access to the mail queue or
the maillogs. I have also tried using both double and single quotes
on my scalars (as suggested by Scott).
Any other ideas? Where would I find the "perldoc -q 'send mail'"
document?
Thanks for trying to help, Raphael,
el
------------------------------
Date: Sat, 14 Jul 2001 22:26:45 GMT
From: Matt D <emdee@DEMUNGEcwcom.net>
Subject: Re: Recommendation for a book covering MySQL and Perl
Message-Id: <0dh1ltkig5qum3ddv7gjpmfvfd1ohkl8tl@4ax.com>
In message-id <9ipkj1$man$1@uranium.btinternet.com>
on Sat, 14 Jul 2001 15:29:14 +0100
'Geoff Soper' issued the following statement:
<snip>
>I know nothing of MySQL and very little of databases so I wonder if anyone
>can recommend a book that would give me a grounding in MySQL from a Perl
>angle. I was looking at the MySQL & mSQL book from O'reilly but it was badly
>reviewed on Amazon. There seems to be plenty on MySQL and PHP but little
>that mentions Perl.
</snip>
i heartily recommend you do NOT buy the o'reilly msql and mysql book..
it's really not worth the money; it's half-baked and just plain WRONG
in places.
as the others have suggested, o'reilly's 'programming the perl dbi' is
a very good book. but at the end of the day, you can't beat the free
online documentation.
--
----------------------------------------
http://specialsource.net/
------------------------------
Date: Sat, 14 Jul 2001 23:22:59 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Regex question
Message-Id: <3B510C93.3C62943F@earthlink.net>
BCC wrote:
>
> How do I begin a match starting at a certain position?
>
> For example, if I have:
> $s = "ABC DEF GHI JKL";
>
> And I want to match after the 8th character to extract "GHI", how do I
> do this?
>
> I looked all over usenet, and the perldocs... I found loads of info on
> how to GET the position, but nothing on how to start matching from a
> position without using pos().
$s = "ABC DEF GHI JKL";
using pos:
pos($s) = 8;
$s =~ /(\w+)/g; # don't do in list context unless you mean it!
$match = $1;
Or:
pos($s) = 8;
($match) = $s =~ /\G.*?(\w+)/; # no /g, so only does one match.
using substr:
($match) = substr($s, 8) =~ /(\w+)/;
or something else:
($match) = unpack("x8a*", $s) =~ /(\w+)/;
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: Sat, 14 Jul 2001 20:52:33 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Using Array and while() loops
Message-Id: <3B50E951.A4BC6173@earthlink.net>
David J Jackson wrote:
>
> Am I making this to difficult? What create an array of server info.
> Grab the info for one of the servers, and print out indivual fields.
>
> Your suggestion are appriciated
> David Jackson
>
> ------------------- partial script -------------
>
> open (BOXES,"servers.txt");
Always, yes, always, check the return value of open.
open( BOXES, "<", "servers.txt" )
or die "Couldn't open servers.txt: $!\n";
> print "Enter Server name ->";$server_name=<STDIN>;chomp($server_name);
You can read and chomp at the same time:
chomp( $server_name = <STDIN> );
> while (<BOXES>) {
> # Parse out server information record
> ($server,$server_alias,$asset,$serial,$ser_make,$ser_model,
> $owner,$location,$dpu_grp,$primary_sa,$os,$os_ver,
> $ip_addr,$status,$purchase,$cs_link,$memory,$drives,
>
> $cpus,$ibm_bkup,$bdkup_sw,$ser_func,$cem,$cem_type,$primary_func,
> $maint_window,$support_level)=split(/[\t\n]/, $_,9999);
Don'y name things you don't need.
my @fields = split;
> # Grab recored for server in question
> if ($server =~/^$server_name/i ) {
Do you really mean for this to be a regular expression? Somehow, I
suspect that what you *really* want is to know if $server starts with
$server_name, *not* whether $server starts with the *pattern*
$server_name.
if( index( $fields[0], $server_name ) == 0 ) {
>
> @sir_info=("$primary_sa\t$dpu_grp\t$asset\n$serial\t$ser_make\t$ser_model\t$location
> \t$support_level");
Are you sure you want to assign a list with one element to @sir_info ?
And the string is ugly. Why not do a join with "\t" ?
@sir_info = ( join "\t", @fields[9,8,2,3,4,5,7,-1] );
> }
> }
> print "$server\n";
> print "$primary_sa\n"
Since this is outside the while loop, this would print the server and
primary_sa from the last line of the file, *not* the one which matches
$server_name.
> ...
> ...
> ...
> exit;
--
The longer a man is wrong, the surer he is that he's right.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1307
***************************************