[17686] in Perl-Users-Digest
Perl-Users Digest, Issue: 5106 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 13 21:10:33 2000
Date: Wed, 13 Dec 2000 18:10:16 -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: <976759816-v9-i5106@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 13 Dec 2000 Volume: 9 Number: 5106
Today's topics:
Perl / CGI? <me@privacy.net>
Re: Perl / CGI? <mbudash@sonic.net>
Re: Perl Newbie Needs Form Script Help passing Data in <mbudash@sonic.net>
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tom Christiansen)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (Tad McClellan)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (John Stanley)
Re: Posting Guidelines for comp.lang.perl.misc ($Revisi (John Stanley)
Re: Printing Vertically (Colin Watson)
Re: Printing Vertically (Tom Christiansen)
Re: Printing Vertically (Randal L. Schwartz)
Re: Printing Vertically <tinamue@zedat.fu-berlin.de>
Re: Printing Vertically <jeffp@crusoe.net>
Re: quick way to search array members <mischief@velma.motion.net>
Rename <johnm@acadiacom.net>
Re: Rename <stephenk@cc.gatech.edu>
Re: Setting timeout with IO::Socket (Charles DeRykus)
SSI and cookies <johnm@acadiacom.net>
win->update() using a forked process <chahn@peregrine.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Dec 2000 23:45:56 GMT
From: "EM" <me@privacy.net>
Subject: Perl / CGI?
Message-Id: <USTZ5.8901$Nw6.29631@news.iol.ie>
whats the difference?
isnt perl a type of cgi or what?
------------------------------
Date: Wed, 13 Dec 2000 15:51:05 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl / CGI?
Message-Id: <mbudash-1215F4.15510513122000@news.pacbell.net>
In article <USTZ5.8901$Nw6.29631@news.iol.ie>, "EM" <me@privacy.net>
wrote:
> whats the difference?
> isn't perl a type of cgi or what?
>
perl is a programming (a.k.a. scripting) language.
CGI is a specification.
perl can be (and often is) used to write scripts conforming to
the CGI spec.
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 13 Dec 2000 15:31:58 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Perl Newbie Needs Form Script Help passing Data in the URL....
Message-Id: <mbudash-B6F2EE.15315813122000@news.pacbell.net>
In article <3a37ee16.22306189@news.supernews.com>,
allen@mail-masters.com (Allen D Moore) wrote:
> Please help!
>
> I am scripting a form in perl which contains numerous fields and need
> to pre-fill data within some of the fields, yet allow the user to
> re-enter different data if required:
>
> print "<input type=\"text\" name=\"name\" size=\"24\"
> value=\"$name\">";
>
> where the refering url would contail data for the $name field...
>
> like: http://www.somesite.com/form.cgi?name=value
>
> What am I missing in order to get the data into the generated form?
>
> TIA!
>
> -Allen
use CGI;
my $cgi = CGI->new();
.
.
.
print '<input type="text" name="name" size="24" value="',
$cgi->param('name'),
'">';
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 13 Dec 2000 17:07:45 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93g0a1.s7.tadmc@maxim.metronet.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
>Tad McClellan wrote:
>
>>How about the below?
>
>>=item Use an effective followup style
>...
>>Intersperse your comments B<following> the sections of quoted text
>>that your comment applies to.
>
>You could also mention the term "Jeopardy style", and why people don't
>like it.
How's this?
-----------------------------------
=item Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Never quote an entire
article. Never quote a .signature (unless that is what you are
commenting on).
Intersperse your comments B<following> the sections of quoted text
that your comment applies to. Failure to do this is called
"Jeopardy" posting (after a TV game show) because the answer
comes before the question. Reversing the chronology of the
dialog makes it much harder to understand (some folks won't even
read it if written in that style).
-----------------------------------
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 13 Dec 2000 14:09:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93flr4.r5.tadmc@maxim.metronet.com>
John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>>On Tue, 12 Dec 2000, tadmc@metronet.com wrote:
>>> =back
>>>
>>> It is B<not> required, or even expected, that you actually I<read>
>
>This is a discussion newsgroup, not a pod newsgroup nor a TeX newsgroup
>nor an HTML newsgroup. It's a bit disengenuous to claim that HTML is not
>welcome here while posting a FAQ in a non-standard (to the rest of the
>world) markup language. HTML has the great advantage that many
>newsreaders process it natively; I know of no pod-based newsreader.
It will not be posted in POD. It will be posted in plain text.
It will be posted in POD while we are word-smithing it, not once
it starts being auto-posted.
I guess I'll need to abandon the "rough outline" code though.
[ snip other comments, all incorporated now. Thanks. ]
>Most people are not gracious when pointing someone to another group, so
>I question the claim that "it is understood".
^^
I changed "is" to "should be".
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 13 Dec 2000 14:10:51 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93flub.r5.tadmc@maxim.metronet.com>
I myself <tadmc@metronet.com> wrote:
>Note my reluctance to let this article get "big". If you'd like
>to argue for more than 4 pages worth go ahead, but I'll treat
>that as a hard requirement unless convinced otherwise.
Doh! That should say "8 pages", not 4 pages.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 13 Dec 2000 17:12:04 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <3a381054@cs.colorado.edu>
In article <slrn93flr4.r5.tadmc@maxim.metronet.com>,
>It will not be posted in POD. It will be posted in plain text.
Perhaps, but you should not _f_o_r_b_i_d people from posting in pod.
Pod is supposed to be "plain old documentation". Any pod not plainly
legible without any further formatting or display mechanism is
fundamentally broken and completely malformed. You might as well
forbid posting of perl.
--tom
------------------------------
Date: Wed, 13 Dec 2000 18:00:30 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93g3cu.12u.tadmc@maxim.metronet.com>
Jeff Zucker <jeff@vpservices.com> wrote:
>Tad McClellan wrote:
>> Naw, let's not go down that slippery slope. I'll change it to:
>>
>> -----------------------------------
>> while ( <> ) {
>> print if /^=head/;
>> print " $_" if /^=item/;
>> }
>> -----------------------------------
>
>Sounds good, though I prefer the output of:
>
>while (<>) {
> print " $1\n" if /^=item\s+(.*)/;
> print " $1\n" if /^=head2\s+(.*)/;
> print "$1\n" if /^=head1\s+(.*)/;
>}
The markup is gone now. So is the outline code.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 13 Dec 2000 18:31:37 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <slrn93g579.12u.tadmc@maxim.metronet.com>
John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>In article <slrn93e2f8.1c0.tadmc@maxim.metronet.com>,
>Tad McClellan <tadmc@metronet.com> wrote:
>>For instance, I plan to make a discussion of killfiles and scoring
>>for those that are not familiar with real newsreading tools.
>
>This is supposed to be a perl discussion group.
I did not say that it would be posted in any newsgroup.
I just said I was going to make one that we could refer folks to.
>>I'll let this article "simmer" for a couple days, and then post the
>>0.2 version for another go-round.
>
>Without pod, please.
There is no more POD.
>> Do we want a "flag" in the Subject for filtering purposes?
>
>Yes. As opposed to Abigail, I want to see neither the FAQ nor any
>responses to it, as all such articles will be off-topic.
The Subject: will always contain "Posting Guidelines".
>I'm interested to know why you think that posting THIS FAQ will have any
>more effect on the way people post than any other FAQ or any of the
>oft-repeated responses to people who post in ways you don't like.
I'm interested to know how you know what I think.
I am, in fact, quite sure that it will fail to have any
significant impact. I don't recall claiming that it will
have any effect on the way people post.
It will only help people who want to fit in, and most don't. They
just want their question answered. "Most" is not "all" though.
>What
>will be special about THIS document that will make them read it and make
>them follow your advice, when we already know they do NOT read such
>documents (even when they are the documents describing perl) and do not
>follow them?
Nothing.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Dec 2000 01:11:27 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <9196nv$sns$1@news.NERO.NET>
In article <3a381054@cs.colorado.edu>,
Tom Christiansen <tchrist@perl.com> wrote:
>In article <slrn93flr4.r5.tadmc@maxim.metronet.com>,
>>It will not be posted in POD. It will be posted in plain text.
>
>Perhaps, but you should not _f_o_r_b_i_d people from posting in pod.
Nice formatting. Rather illegible, but I suppose it means something.
>Pod is supposed to be "plain old documentation". Any pod not plainly
>legible without any further formatting or display mechanism is
>fundamentally broken and completely malformed.
HTML can be just as plain as pod. <i> Yes, it can be. </I>
>You might as well forbid posting of perl.
This is a perl newsgroup. When the group changes name to
comp.lang.pod.misc, then it will be correct to post pod. If you object
to HTML and claim it should be prohibited, then you've tarred pod with
the same brush. Both are markup languages.
------------------------------
Date: 14 Dec 2000 01:18:25 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 0.1 $)
Message-Id: <919751$soo$1@news.NERO.NET>
In article <slrn93g579.12u.tadmc@maxim.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>John Stanley <stanley@skyking.OCE.ORST.EDU> wrote:
>>In article <slrn93e2f8.1c0.tadmc@maxim.metronet.com>,
>>Tad McClellan <tadmc@metronet.com> wrote:
>>>For instance, I plan to make a discussion of killfiles and scoring
>>>for those that are not familiar with real newsreading tools.
>>
>>This is supposed to be a perl discussion group.
>
>I did not say that it would be posted in any newsgroup.
>
>I just said I was going to make one that we could refer folks to.
Ok, fine. But from the context, it is easy to think that you intended it
to be part of what is posted.
>There is no more POD.
Thank you.
>>> Do we want a "flag" in the Subject for filtering purposes?
>>
>>Yes. As opposed to Abigail, I want to see neither the FAQ nor any
>>responses to it, as all such articles will be off-topic.
>
>The Subject: will always contain "Posting Guidelines".
Thank you. You should also include a known From:, however, so it would
be possible to archive the guidelines and send them to anyone who
subscribes to the digest version of the group.
>>I'm interested to know why you think that posting THIS FAQ will have any
>>more effect on the way people post than any other FAQ or any of the
>>oft-repeated responses to people who post in ways you don't like.
>
>I'm interested to know how you know what I think.
I assumed that you were taking your time to produce a document telling
people how to post properly because you wanted them to follow the
suggestions. I'm asking why you think that they will follow your
suggestions when they don't follow any others.
>I am, in fact, quite sure that it will fail to have any
>significant impact. I don't recall claiming that it will
>have any effect on the way people post.
Then why are you spending the time doing this? If it has no effect, then
it is adding to the clutter. Is that your goal?
------------------------------
Date: 13 Dec 2000 23:11:58 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: Printing Vertically
Message-Id: <918vnu$9no$1@riva.ucam.org>
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>Since that would be cheating, here's another one
>
>map{print}/./sg
>
>(requires the l flag, so 15+1, or +2 if you count the - sign :)
Not quite as short, counting flags (13+7 or 13+9), but still quite cute:
perl -alpF// -e '$"=$/;$_="@F"'
--
Colin Watson [cjw44@flatline.org.uk]
"Choose mnemonic identifiers. If you can't remember what
mnemonic means, you've got a problem." - perlstyle(1p)
------------------------------
Date: 13 Dec 2000 17:00:54 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Printing Vertically
Message-Id: <3a380db6@cs.colorado.edu>
^ ^ ^ ^ ^ ^ ^ ^
I < K w a p i h
n 9 6 r r n o
1 o p i s r
a 6 < t r n t i
r b b e o t e z
t m l : b a o
i g n l a d n
c $ u I e t
l h k ' m v o a
e t e v , a f l
1 m e l .
$ @ I u n
1 h r e o
@ o u n r a
n t n e v m n
e m e e a y
w a i d r l
s i n t i
. l t t i d
m . o o c e
o c a a
n o l s
m m l ?
o > y
u
t
h
.
c
o
m
>
,
I o y s p t f s i
t o e o h e o f
d h u e i i e m
o e r m n s l e y
n r e t t o
' p d . b f h u
t r o e r i '
e s t t e n d
t s t o I t e g
h p i f e l
i o n g r t l i
n n g e y , o i k
k s t o k e
e r u p u e .
t s e t l s
h a h l e e t
a t l e i a h
t o l k s i
y e e s
t
h
e
#!/usr/bin/perl
# rot90 - tchrist@perl.com
$/ = '';
# uncomment for easier to read, but not reversible
#@ARGV = map { "fmt -20 $_ |" } @ARGV;
while ( <> ) {
chomp;
@lines = split /\n/;
$MAXCOLS = -1;
for (@lines) { $MAXCOLS = length if $MAXCOLS < length; }
@vlines = ( " " x @lines ) x $MAXCOLS;
for ( $row = 0; $row < @lines; $row++ ) {
for ( $col = 0; $col < $MAXCOLS; $col++ ) {
$char = ( length($lines[$row]) > $col )
? substr($lines[$row], $col, 1)
: ' ';
substr($vlines[$col], $row, 1) = $char;
}
}
for (@vlines) {
# uncomment for easier to read, but not reversible
s/(.)/$1 /g;
print $_, "\n";
}
print "\n";
}
------------------------------
Date: 13 Dec 2000 16:54:01 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Printing Vertically
Message-Id: <m17l53yg9i.fsf@halfdome.holdit.com>
>>>>> "Tom" == Tom Christiansen <tchrist@perl.com> writes:
Tom> #!/usr/bin/perl
Tom> # rot90 - tchrist@perl.com
Tom> $/ = '';
Tom> # uncomment for easier to read, but not reversible
Tom> #@ARGV = map { "fmt -20 $_ |" } @ARGV;
Tom> while ( <> ) {
Tom> chomp;
Tom> @lines = split /\n/;
Tom> $MAXCOLS = -1;
Tom> for (@lines) { $MAXCOLS = length if $MAXCOLS < length; }
Tom> @vlines = ( " " x @lines ) x $MAXCOLS;
Tom> for ( $row = 0; $row < @lines; $row++ ) {
Tom> for ( $col = 0; $col < $MAXCOLS; $col++ ) {
Tom> $char = ( length($lines[$row]) > $col )
Tom> ? substr($lines[$row], $col, 1)
Tom> : ' ';
Tom> substr($vlines[$col], $row, 1) = $char;
Tom> }
Tom> }
Tom> for (@vlines) {
Tom> # uncomment for easier to read, but not reversible
Tom> s/(.)/$1 /g;
Tom> print $_, "\n";
Tom> }
Tom> print "\n";
Tom> }
Far too BASIC-like for my taste. Let's use some Perl-ish things:
chomp(my @lines = <DATA>);
print join(" ", map { s/(.)//s ? $1 : " " } @lines), "\n"
while length join "", @lines;
__END__
Whoa. I didn't
expect it
to be THAT short.
:-)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 14 Dec 2000 01:47:41 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Printing Vertically
Message-Id: <9198rt$3a96v$2@fu-berlin.de>
Abigail <abigail@foad.org> wrote:
> Saving 3 strokes:
> s/./$&\n/g;print;
saving 2 strokes (ok, without the semikolon):
s//$&\n/g;print
neat, but longer:
s=.=warn$&.$/=eg
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Wed, 13 Dec 2000 20:56:55 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Printing Vertically
Message-Id: <Pine.GSO.4.21.0012132056120.19179-100000@crusoe.crusoe.net>
On Dec 14, Tina Mueller said:
>Abigail <abigail@foad.org> wrote:
>> Saving 3 strokes:
>
>> s/./$&\n/g;print;
>
>saving 2 strokes (ok, without the semikolon):
>
> s//$&\n/g;print
Sorry, tina, but that includes a newline at the beginning of the string
(where there ought not to be one).
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
PerlMonks - An Online Perl Community http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
------------------------------
Date: Thu, 14 Dec 2000 00:55:30 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: quick way to search array members
Message-Id: <t3g6k2c9k5ls64@corp.supernews.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> Ren Maddox wrote:
>>You may be thinking of "grep", but you should avoid that for this
>>purpose as it will always search the entire array even if the element
>>is found at the beginning of the array. This can be quite wasteful.
> Bogus. A search that aborts as soon as a match is found, will on average
> still need to go through half of the items. For an item that isn't
> there, you'll need to go through all of them anyway. If the likeliness
> that what you're looking for isn't there, increases, the average number
> of items that you need to search through will increase as well, i.e.
> more than half of the total.
A 50% time savings on average is signifigant. You should program both
to keep the worst case livable and to make the best case as good as
reasonably possible. As the likeliness that you will find what you
are looking for increases, the time needed to search definitely
decreases with certain methods and is likely to decrease on average
with most methods of search.
> Building a hash to search for just one element, that is what I call
> wasteful.
Building an array just to search for one element is just as wasteful.
It may use a bit less memory, but it uses more running time. If
the program really only searches for one possible value, then it
doesn't really need to search. If it searches for one possibly
variable value at each run, it's likely trivial and the methods
won't matter much unless it's perfoming the search on a huge
data source or is being run many times simultaneously, like perhaps
a database front end or a CGI script.
A search, btw, can search on average many fewer than half the
number of entries, given the right circumstances. A binary
search, for example, is reasonably close to O(log(n)). It does,
however, require a tree or something that can function as a
tree. That can add time, but if it builds a tree once and
searches the tree many times, you've cut down running time
enormously.
Chris
--
Christopher E. Stith - mischief@velma.motion.net
------------------------------
Date: Wed, 13 Dec 2000 19:00:41 -0600
From: "John Michael" <johnm@acadiacom.net>
Subject: Rename
Message-Id: <3a381ce2@news.acadiacom.net>
Is there anyway to rename a directory in perl or with a pipe command to
system.
It looks like to me that the only way to do it is to create a new directory,
move the contents of the old and unlink the old.
Thanks
John Michael
------------------------------
Date: Wed, 13 Dec 2000 20:07:43 -0500
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: Rename
Message-Id: <3A381D5E.38974A5C@cc.gatech.edu>
John Michael wrote:
> Is there anyway to rename a directory in perl or with a pipe command to
> system.
> It looks like to me that the only way to do it is to create a new directory,
> move the contents of the old and unlink the old.
>
perldoc -f rename
It seems to work for directories in Win32 and SunOS UNIX.
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Wed, 13 Dec 2000 23:29:51 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Setting timeout with IO::Socket
Message-Id: <G5J59r.9y4@news.boeing.com>
In article <slrn93csqu.kof.esper@pchan.sherohman.org>,
Dave Sherohman <esper@news.visi.com> wrote:
>(I asked this question in comp.lang.perl.modules yesterday, but have yet to
>get any responses, so I'm bringing it over to .misc. I'd rather have just
>left it in .modules, but that group doesn't seem to be very active...)
>
>...
>Anyhow, I figure the best way to handle this sweep for orphaned requests is
>to slap a timeout on my recv call so that it will be performed whenever X
>minutes pass without any activity. All the examples I've been able to turn
>up on the web essentially boil down to 'die on timeout' (which is not
>appropriate here) implemented using SIGALRM. I don't think a signal handler
>is the correct approach here - sweeping through a hash of hashes (hash of
>requests with a hash of request details for each) and examining them all
>takes longer than I'm comfortable with in a signal handler. Plus, some 'old'
>entries will be deleted on the assumption that they were orphaned by UDP
>delivery failures instead of server failure; modifying data in signal
>handlers is generally considered to be a Bad Thing as well.
>
>The obvious solution,
>
>---
>my $socket = IO::Socket::INET->new( LocalPort => $port,
> Proto => 'udp',
> Timeout => 1
> );
>
>while (1) {
> my $sender = $socket->recv(my $datagram, 8192);
> print "Recv completed.\n";
>}
>---
>
>has been running for over an hour and has yet to time out. (If I send
>something to it, the datagram is received intact; no problems there. But it
>never times out.)
>
>What do I need to do to make this work the way I intended? Also, if a
>timeout does occur, am I correct in assuming that $sender would be undef, or
>is there some other way to distinguish a timeout from a successful recv?
>
If I remember correctly, I believe the constructor's own
timeout will only kick in on its connect(2) and accept(2)
calls. Unless you've set O_NONBLOCK, recv will just block
but you could wrap the recv in an eval (perldoc perlipc for
details):
Here's a possibility, e.g.,
eval { local $SIG{__DIE__} = 'DEFAULT';
local $SIG{__ALRM__} = sub { die 'timeout!' };
alarm(10);
defined(recv(...)) or die "recv failed: $!";
alarm(0);
};
alarm(0);
if ($@ =~ /^timeout!/) { # timeout
...
} elsif ($@ =~ /^recv failed:/) { # recv error
...
} elsif ($@) # unexpected eval error
...
}
hth,
--
Charles DeRykus
------------------------------
Date: Wed, 13 Dec 2000 19:17:36 -0600
From: "John Michael" <johnm@acadiacom.net>
Subject: SSI and cookies
Message-Id: <3a3820d8$1@news.acadiacom.net>
Is it possible to send/set a cookie to a browser with a server side include
that calls a script. I have an html page that has a server side include on
it to run a script. The script then returns specific html to the surfer
depending on information I have gathered from envirionmental variables. I
would like to be able to set a cookie, but the server won't send the cookie
header. It does print the page. I could add a clear image on the page to
set the cookie, but would like to do it in one swoop.
John M
------------------------------
Date: Wed, 13 Dec 2000 17:44:05 -0800
From: "Christopher Hahn" <chahn@peregrine.com>
Subject: win->update() using a forked process
Message-Id: <9198lt$amk$1@dfw-ixnews3.ix.netcom.com>
Hello,
I am facing the age-old problem of having my Perl-Tk
interface appear locked up because my read from a pipe is
blocking.
This is to say:
=================================
open(BPIPE, "command_name |");
while (<BPIPE>) {
LogMessage "LINE:$_\n";
$HMain->update();
}
=================================
Because I only see the call to update() every
time output becomes available from the pipe, the interface
appears to be frozen, for example it will not repaint
itself when uncovered.
So, what I want to do is fork off a child in which to run the
command and log the output, with the parent calling update
every second or two.
..but I am using AS Perl 5.6 on windows 2000 :-( !!!
Stealing from the fork example from the Camel book i try:
========================================
use Errno qw(EAGAIN);
use POSIX ":sys_wait_h";
my $pid;
my $chld;
FORK: {
if ($pid = fork) {
#parent process
do {
$chld = waitpid(-1,&WNOHANG);
$HMain->update();
sleep 2;
} unless $chld == -1;
} elsif (defined $pid) {
open(BPIPE, "msdev sc.dsw /MAKE \"$i - ALL\" |");
while (<BPIPE>) {
LogMessage "LINE: " . <BPIPE> . "\n";
$HMain->update();
}
} else {
die "Could not fork: $!\n";
}
}
========================================
Here the do-until of the first claus is intended (sic) to update
the interface every 2 seconds until the child process dies.
(This is what I need!!!)
BUT this produced an access exception and crashed the Perl-Tk app.
So....what is the recommended method (on win32!) for waiting
and updating an interface while a long running command runs.
Pardon the long-windedness, but TIA for any ideas.....
Christopher
------------------------------
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 5106
**************************************