[21870] in Perl-Users-Digest
Perl-Users Digest, Issue: 4074 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 6 18:07:16 2002
Date: Wed, 6 Nov 2002 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 6 Nov 2002 Volume: 10 Number: 4074
Today's topics:
$@ true, but empty? (Chris)
Re: $@ true, but empty? <kurzhalsflasche@netscape.net>
Re: $@ true, but empty? <goldbb2@earthlink.net>
Re: $@ true, but empty? (Malcolm Dew-Jones)
A Unix guy moving to Windows 2000 stan@temple.edu
Re: A Unix guy moving to Windows 2000 <matt@no.spam.please>
Re: A Unix guy moving to Windows 2000 <tk@WINDOZEdigiserv.net>
Re: A Unix guy moving to Windows 2000 <mothra@nowhereatall.com>
Re: A Unix guy moving to Windows 2000 <spam@all.costs.must.die>
Re: A vision for Parrot <bilotta78@hotpop.com>
Re: A vision for Parrot (Laotseu)
Re: CGI Upload Problems <stedman@siam.org>
Re: CGI Upload Problems <flavell@mail.cern.ch>
Re: Do scripts use the CPU while sleeping? <goldbb2@earthlink.net>
Re: Do scripts use the CPU while sleeping? (Malcolm Dew-Jones)
Re: don't understand use strict; nobull@mail.com
Re: file order in opendir DH <ddunham@taos.com>
Re: fork() and socket? <goldbb2@earthlink.net>
Re: How much faster is dbm over MySQL (Tad McClellan)
Re: How to guarantee process ID stays with web connecti <spam@thecouch.homeip.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Nov 2002 11:48:00 -0800
From: chuegle@hotmail.com (Chris)
Subject: $@ true, but empty?
Message-Id: <4e5f15a2.0211061148.3328baf1@posting.google.com>
I'm running into a problem with the following code running in
mod_perl:
eval {
&function();
};
if($@) {
print"Error: $@";
}
Occasionally, an Error would be printed but $@ would be an empty
string.
length($@) will be equal to 0.
I can't seem to recreate this in a test environment, but its happening
fairly frequently in the live environment (of course, &function is
pretty complicated, multi-library code.)
First, can anyone explain to me how $@ can evaluate to true but yet be
empty? (ie I was under the impression that if($var) was about the same
as if(defined($var) && $var ne '' && $var != 0), but this doesn't seem
to be true)
Second, anyone have any idea what can be causing $@ to be empty but
true?
Thanks in advance!
Chris
------------------------------
Date: Wed, 06 Nov 2002 21:04:29 +0100
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: $@ true, but empty?
Message-Id: <3DC975CD.1060203@netscape.net>
Chris announced:
> I'm running into a problem with the following code running in
> mod_perl:
>
> eval {
> &function();
> };
>
> if($@) {
> print"Error: $@";
> }
>
> Occasionally, an Error would be printed but $@ would be an empty
> string.
> length($@) will be equal to 0.
>
> I can't seem to recreate this in a test environment, but its happening
> fairly frequently in the live environment (of course, &function is
> pretty complicated, multi-library code.)
>
> First, can anyone explain to me how $@ can evaluate to true but yet be
> empty? (ie I was under the impression that if($var) was about the same
> as if(defined($var) && $var ne '' && $var != 0), but this doesn't seem
> to be true)
>
> Second, anyone have any idea what can be causing $@ to be empty but
> true?
>
> Thanks in advance!
> Chris
'0 but true' (or '0E0' in DBI) is used in Perl to signal that a method
was succesfully completed but the result is zero ('0' as a return code
would cause 'if (function()' to be false).
HTH,
Dominik
------------------------------
Date: Wed, 06 Nov 2002 15:42:40 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: $@ true, but empty?
Message-Id: <3DC97EC0.C3B1976B@earthlink.net>
Dominik Seelow wrote:
>
> Chris announced:
[snip]
> > First, can anyone explain to me how $@ can evaluate to true but yet
> > be empty? (ie I was under the impression that if($var) was about the
> > same as if(defined($var) && $var ne '' && $var != 0), but this
> > doesn't seem to be true)
> >
> > Second, anyone have any idea what can be causing $@ to be empty but
> > true?
>
> '0 but true' (or '0E0' in DBI) is used in Perl to signal that a method
> was succesfully completed but the result is zero ('0' as a return code
> would cause 'if (function()' to be false).
Ahh, but the string "0 but true", and "0E0" both have lengths, they are
not empty.
The only thing which I could think of that might produce the results the
OP has, is if you've done die($object), where $object is blessed into a
class with overloaded '""' and 'bool' operators, where the 'bool'
conversion produces true and the '""' conversion produces an empty
string.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 6 Nov 2002 14:57:59 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: $@ true, but empty?
Message-Id: <3dc99e77@news.victoria.tc.ca>
Benjamin Goldberg (goldbb2@earthlink.net) wrote:
: Dominik Seelow wrote:
: >
: > Chris announced:
: [snip]
: > > First, can anyone explain to me how $@ can evaluate to true but yet
: > > be empty? (ie I was under the impression that if($var) was about the
: > > same as if(defined($var) && $var ne '' && $var != 0), but this
: > > doesn't seem to be true)
: > >
: > > Second, anyone have any idea what can be causing $@ to be empty but
: > > true?
: >
: > '0 but true' (or '0E0' in DBI) is used in Perl to signal that a method
: > was succesfully completed but the result is zero ('0' as a return code
: > would cause 'if (function()' to be false).
: Ahh, but the string "0 but true", and "0E0" both have lengths, they are
: not empty.
: The only thing which I could think of that might produce the results the
: OP has, is if you've done die($object), where $object is blessed into a
: class with overloaded '""' and 'bool' operators, where the 'bool'
: conversion produces true and the '""' conversion produces an empty
: string.
Variables can have magic associated with them. I think that the $!
variable is so blessed. Perhaps $@ is another such variable. The magic
might allow them to be true or false independently of the string value of
the variable.
Also, since perl can "cache" the different polymorphic versions of a
variable, perhaps the string value and the boolean (numeric?) value could
be out of sync, which sounds like it could tie into my theory of magic.
However, the above is based on little more than rumours and potential
misunderstandings.
------------------------------
Date: 6 Nov 2002 19:43:02 GMT
From: stan@temple.edu
Subject: A Unix guy moving to Windows 2000
Message-Id: <aqbrc6$krm$1@cronkite.temple.edu>
I am in the process of migrating a Unix system who's primary
purpose in life is to run L-Soft's Listserv software to a Windows
2000 Advanced Server system. On this Unix system, I have developed
roughly one dozen Perl scripts over the years that do various
things from generating reports on how many lists we are hosting
and also CGI scripts to allow our help desk to create lists on
the fly.
My attempt to convert a simple reporting script is not going well.
This difference between the Windows and Unix file systems is
very confusing to me.
I installed the Cygwin utilities on this Windows system and the
Perl that comes with it. I then wrote a Perl script in a Cygwin
shell. This script works fine if I run it in a Cygwin shell window.
When I open up a Windows command window and run the script, it
can't find the disks and files that it can in the Cygwin system.
How can I make my Perl programs run under both environments?
I have looked all through the cpan and perl.com web sites for
info on this, but I came up empty handed. I searched on Microsoft's
site for info on Perl programming and I read through two books
on Perl programming (the O'Reilly Cookbook and Programmer's Guide)
and I also came up empty handed.
To illustrate a little bit of what I want to achieve, I have prepared
a small test program which works fine under a Cygwin window, but not
when I try to run it via a Windows command window. I want to know
how to adapt this program so that it runs under both environments
so that I can schedule it via the Windows Task Scheduler.
Here's the program:
#!/usr/bin/perl -w
print "Hello world!\n";
system("date > date.output");
system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
system("pwd");
system("df -k");
print "Hello world again!\n";
exit;
------------------------------
Date: Wed, 06 Nov 2002 20:19:07 GMT
From: "matt" <matt@no.spam.please>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <%Oey9.129145$wG.483037@rwcrnsc51.ops.asp.att.net>
<stan@temple.edu> wrote in message news:aqbrc6$krm$1@cronkite.temple.edu...
<snip>
> I installed the Cygwin utilities on this Windows system and the
> Perl that comes with it
<snip>
>
> #!/usr/bin/perl -w
>
> print "Hello world!\n";
> system("date > date.output");
> system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
> system("pwd");
> system("df -k");
> print "Hello world again!\n";
>
> exit;
>
Windows path's are very different than unix. Basically, windows doesn't know
what /cygwin/c is. The equvilant in windows is c:\. To make this work you
either have to change the path's in your scripts from /cygwin/c to c:\\
(don't forget to escape the \'s), or call bash in your system() call, ie.,
system("bash ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
You will need to make sure your windows %PATH% env. variable points to the
bin directory where you installed cygwin, something like c:\cygwin\usr\bin .
Hope this helps.
-- Matt
------------------------------
Date: Wed, 06 Nov 2002 20:27:17 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <lguisuke6eh828696oqjjl5gr879kubrop@4ax.com>
In a fit of excitement on 6 Nov 2002 19:43:02 GMT, stan@temple.edu
managed to scribble:
| I am in the process of migrating a Unix system who's primary
| purpose in life is to run L-Soft's Listserv software to a Windows
| 2000 Advanced Server system. On this Unix system, I have developed
| roughly one dozen Perl scripts over the years that do various
| things from generating reports on how many lists we are hosting
| and also CGI scripts to allow our help desk to create lists on
| the fly.
|
| My attempt to convert a simple reporting script is not going well.
| This difference between the Windows and Unix file systems is
| very confusing to me.
|
| I installed the Cygwin utilities on this Windows system and the
| Perl that comes with it. I then wrote a Perl script in a Cygwin
| shell. This script works fine if I run it in a Cygwin shell window.
| When I open up a Windows command window and run the script, it
| can't find the disks and files that it can in the Cygwin system.
| How can I make my Perl programs run under both environments?
|
| I have looked all through the cpan and perl.com web sites for
| info on this, but I came up empty handed. I searched on Microsoft's
| site for info on Perl programming and I read through two books
| on Perl programming (the O'Reilly Cookbook and Programmer's Guide)
| and I also came up empty handed.
|
| To illustrate a little bit of what I want to achieve, I have prepared
| a small test program which works fine under a Cygwin window, but not
| when I try to run it via a Windows command window. I want to know
| how to adapt this program so that it runs under both environments
| so that I can schedule it via the Windows Task Scheduler.
|
| Here's the program:
|
| #!/usr/bin/perl -w
|
| print "Hello world!\n";
| system("date > date.output");
| system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
| system("pwd");
| system("df -k");
| print "Hello world again!\n";
|
| exit;
|
The big problems I see here is
1:> Command names
2:> Filesystem (ie: slashes)
For the date part, I'd use Perl's date function and write that to a
file.
'ls' ya wanna swap for 'dir'. If using doublequotes ("") you'll need to
escape the backslashes for windoze as you'll probably know/realise.
system("dir c:\\listserv\\main\\*.LIST > lists.stuff");
(remember also, filenames are _NOT_ case sensitive on windoze, so dont
make a mistake and write a file like LISTS.DAT and Lists.dat as it'll be
overwritten).
'pwd' you wanna swap to 'cd' for "current dir".
As for 'df', I dont know off the top of me head any windoze command to
display the same partition info. Might have to think about writing that
part yaself from within Perl, but from what I can gather so far, might
take a while as you're a UNIX person rather than windoze.
Hope this helps a lil =)
Regards,
tk
--
use strict;my(@t)= (chr( 114),
chr(115),chr(109), chr ( 126),
chr( 121), chr(
106) ,chr(114),
chr( 115), chr(
111) ,chr( 36),
chr( 112), chr(
101),chr(120),chr(115),chr(120));foreach
(reverse(@t)){print(chr(ord($_)-(1<<2)))};
------------------------------
Date: Wed, 6 Nov 2002 12:45:43 -0800
From: "Mothra" <mothra@nowhereatall.com>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <3dc97f2e$1@usenet.ugs.com>
<stan@temple.edu> wrote in message news:aqbrc6$krm$1@cronkite.temple.edu...
[snipped]
> #!/usr/bin/perl -w
>
> print "Hello world!\n";
> system("date > date.output");
> system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
> system("pwd");
> system("df -k");
> print "Hello world again!\n";
>
> exit;
To write portable perl code take a look at
perldoc perlport
NAME
perlport - Writing portable Perl
------------------------------
Date: Thu, 7 Nov 2002 08:40:12 +1100
From: "Tintin" <spam@all.costs.must.die>
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <3dc98c6f_1@news.iprimus.com.au>
<stan@temple.edu> wrote in message news:aqbrc6$krm$1@cronkite.temple.edu...
> I installed the Cygwin utilities on this Windows system and the
> Perl that comes with it. I then wrote a Perl script in a Cygwin
> shell. This script works fine if I run it in a Cygwin shell window.
> When I open up a Windows command window and run the script, it
> can't find the disks and files that it can in the Cygwin system.
> How can I make my Perl programs run under both environments?
By writing portable code. Your example below is not what I'd call good use
of Perl.
> To illustrate a little bit of what I want to achieve, I have prepared
> a small test program which works fine under a Cygwin window, but not
> when I try to run it via a Windows command window. I want to know
> how to adapt this program so that it runs under both environments
> so that I can schedule it via the Windows Task Scheduler.
>
> Here's the program:
>
> #!/usr/bin/perl -w
>
> print "Hello world!\n";
> system("date > date.output");
> system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
> system("pwd");
> system("df -k");
> print "Hello world again!\n";
>
> exit;
I think we'll have to start awarding the UUOP (Useless Use of Perl).
Anyway, enough flames.
If you want to run cygwin commands/scripts under a Windows environment, then
you need to create a batch wrapper. A prime example is the batch file to
invoke cygwin itself, ie: C:/cygwin/cygwin.bat
Use that as a template and call your Perl script via the shell.
------------------------------
Date: Wed, 6 Nov 2002 20:27:04 +0100
From: Giuseppe Bilotta <bilotta78@hotpop.com>
Subject: Re: A vision for Parrot
Message-Id: <MPG.18338b701ef6b0b598acda@News.CIS.DFN.DE>
Robin Becker wrote:
> In article <aqbimo$a36$1@news.ox.ac.uk>, Frodo Morris
> .
> .....
> >> The problem that people keep forgetting is that Turing Equivilence
> >> requires indefinite memory. Turing Machines are defined as having
> >> infinite "tapes". Given any finite memory size, I can come up with
> >> an interpreter the emulation of which would not fit in that finite
> >> memory size.
> >Perdantick bast. :-)
> >Imagine if parrot could understand all currently- and popularly-
> >implemented interpreted languages.
> >
> which language was it that got kicked to death by the others?
>
XML, but it wasn't a programming language. And they all kicked to
death because XML parsing is now considered a MUST for any "sane"
language.
--
Giuseppe "Oblomov" Bilotta
"Da grande lotterņ per la pace"
"A me me la compra il mio babbo"
(Altan)
("When I grow up, I will fight for peace"
"I'll have my daddy buy it for me")
------------------------------
Date: 6 Nov 2002 14:32:47 -0800
From: bdesth@free.fr (Laotseu)
Subject: Re: A vision for Parrot
Message-Id: <4f49d232.0211061432.593d46b@posting.google.com>
Frodo Morris <graham.lee@wadham.ox.ac.uk> wrote in message news:<aq8g9u$6c7$1@news.ox.ac.uk>...
> Cameron Laird wrote:
(snip some)
> that's what I call the conducting
> machine: "Apple" because it sends Jobs away, does nothing for a while
> then gets Jobs back :-)
lol :-))))
(snip some more)
Laotseu
------------------------------
Date: Wed, 6 Nov 2002 13:54:21 -0500
From: "Josh Stedman" <stedman@siam.org>
Subject: Re: CGI Upload Problems
Message-Id: <xPdy9.20464$T_.505059@iad-read.news.verio.net>
"Doug" <dgardiner@houston.rr.com> wrote in message
news:CI3y9.281655$121.8252034@twister.austin.rr.com...
>
> Did I miss something, other than the lack of action tag calling the script,
> or was it in the OP.
>
>
Don't need an action tag... the default is to call itself. Guess where the form resides? ;)
The script is called. If no parameters passed, it prints the form. If it has bad values in the
required fields, it prints a modified version of the form highlighting the bad values, and filling
in what was passed. If all is well, it uploads any files that were provided, logs the information
on the server (if a logfile was defined), and emails it where it's supposed to go.
All in all, it's a script to take submissions to a website, with a selection for which section of
the site. The section picked defines where the email should go.
And it's all working now, which is the best part! ;)
------------------------------
Date: Wed, 6 Nov 2002 22:34:11 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI Upload Problems
Message-Id: <Pine.LNX.4.40.0211062217260.15931-100000@lxplus075.cern.ch>
On Nov 6, Josh Stedman inscribed on the eternal scroll:
> Don't need an action tag...
For the meaning of the word "tag", see
http://www.flightlab.com/~joe/sgml/faq-not.txt part 5. [1]
What we have here is the action _attribute_, of the form tag.
> the default is to call itself.
That used to be the case in earlier HTML specifications, and probably
it's what browsers will do anyway, but for some strange reason the
omission of the action attribute is no longer permitted according to
the spec, and will raise a syntax validation error.
> The script is called. If no parameters passed, it prints the form.
[...]
Sure, I'm not arguing against that - it's often a very appropriate
choice.
But technically, one _is_ required to supply an action attribute,
even if it's the same script. See e.g
http://www.w3.org/TR/html401/interact/forms.html#h-17.3
action %URI; #REQUIRED -- server-side form handler --
Sorry, I know this is OT for the group, but if the issue is going to
be raised anyway, I felt it better be accurate.
cheers
[1] Check the posting date!
------------------------------
Date: Wed, 06 Nov 2002 15:35:55 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Do scripts use the CPU while sleeping?
Message-Id: <3DC97D2B.348372BE@earthlink.net>
Jonathan Lonsdale wrote:
[snip]
> I'm wondering how people usually approach this for email-a-friend type
> services. A script I've got in development does this:
>
> 1. When the page is requested generates a hash of the client's IP and
> user-agent. Embeds this in a hidden field.
> 2. When the page is submitted the integrity of the hash is checked.
> 3. Requests are logged to a MySQL database by IP and date/time.
> 4. Requests fail if:
> A) a previous one was issued from the same IP less than 3 seconds ago
> or
> B) more than 50 requests issued from the IP in a day.
>
> How effective is this and what further improvements could be added
> without compromising the functions useabilty?
Check that no more than one request to send to a particular email
address is made in a day. Canonicalize email addresses before checking
for equality, otherwise an attacker could one email to each of
joe@xyzzy.net, joe@Xyzzy.net, joe@xYzzy.net, joe@XYzzy.net, etc. (With
N alphabetic letters in the domain-part, there are 2**N different
capitalizations).
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 6 Nov 2002 12:31:09 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Do scripts use the CPU while sleeping?
Message-Id: <3dc97c0d@news.victoria.tc.ca>
Jonathan Lonsdale (jon3001@hotmail.com) wrote:
: I'm wondering how people usually approach this for email-a-friend type
: services. A script I've got in development does this:
Most of us don't usually come anywhere near this type of service in this
format, it's much too easy for it to become spammish, even if the mail is
genuinely sent from someone you know. I can guaranty that if your site is
in the least successful then it will likely and quickly enter a variety of
email black lists, and then you won't be able to send any mail at all to
many people.
The usual alternative is to push some text into a mailto: and let the user
use their own email account to send the mail. You just help them setup
the message in the first place. There are limitations on what you can do
with a mailto url, but I've seen some fairly complex examples, so I think
it can work reasonably well.
You can also set up your own message exchange system on your own server,
to be used by people who sign up as members on your system. There are
lots of those systems around as examples. The members can send all the
messages they like to each other, because that's what everyone on that
system has signed up for.
------------------------------
Date: 6 Nov 2002 11:06:58 -0800
From: nobull@mail.com
Subject: Re: don't understand use strict;
Message-Id: <4dafc536.0211061106.585f9d8c@posting.google.com>
"J rgen Exner" <jurgenex@hotmail.com> wrote in message news:<qQyx9.12277$t1.11826@nwrddc02.gnilink.net>...
> [Please don't post jeopardy style; answers re-arranged into chronological
> order]
> henrik nilsson wrote:
> > However, I was under the impression that you, if you my-declare @err
> > in the main body of your program, would limit the scope of @err to
> > the main body only,
>
> Right.
>
> > so that you wouldn't be able to read @err from
> > inside a subroutine?
>
> But subroutines are part of the main body, aren't they?
> BTW: those variable are commonly called global
Actually in Perl they are more commonly (and more correctly) called
"file scoped". This still isn't pedantically 100% correct but it's
better.
The term "global" is more often applied in Perl to package scoped
variables.
Of course this lead to the ugly phrase "globally global" to describe
variables like @INC that are truely global. :-)
> > And that you, if my-declaring $value inside a subroutine, wouldn't be
> > able to "return $value;" to the main body of the program?
>
> Please distinguish between a variable and its value.
> The variable $value is visible inside the sub only and in 99.9% of all cases
> this is a good thing.
> When you are using "return $value", then the sub returns the current
> value(!) of the local variable $value (not the variable itself!) to the
> calling routine.
Except, of course, in an lvalue sub. But even in an lvalue sub the
name clash doesn't doesn't matter because it is the variable and not
its name that is returned.
------------------------------
Date: Wed, 06 Nov 2002 20:55:23 GMT
From: Darren Dunham <ddunham@taos.com>
Subject: Re: file order in opendir DH
Message-Id: <Xns92BE8373FFF05ddunhamtaoscom@64.164.98.29>
"Chris Harris" <chris.harris@cwfi.co.fk> wrote in
news:aqbm8k$87a3h$1@ID-134007.news.dfncis.de:
> I have a script that writes a webpage that displays a directory of
> thumbnail images that are archived from a webcam. It works, however it
> is important that the images are displayed in chronological order and
> for some reason this isn't happening. The script is run as cronjob
> hourly and for some reason new images occasionally appear amongst the
> old ones instead of adding onto the end.
readdir reads in "directory order". There is no sorting. You can read
them into an array and then sort the array yourself if you would like.
It's the same order you'd get on unix if you did a 'ls -f'. If files were
never deleted, it would be the order they were created. However, once
files are deleted it creates "holes" in the directory, and some new files
will fill those holes, so the order is no longer chronological.
> Anybody any ideas on what is going wrong and how to sort it out,, or
> should that be sort the output?
> my $dir = "images/webcam";
> opendir DH, $dir or die "Cannot open $dir: $!";
> foreach $file (readdir DH) {
Change that to
my @sorted_files = sort (readdir DH);
foreach $file (@sorted_files) {
and you'll do them in sorted order...
--
Darren Dunham
ddunham@taos.com
------------------------------
Date: Wed, 06 Nov 2002 15:26:20 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: fork() and socket?
Message-Id: <3DC97AEC.FB76E8C4@earthlink.net>
edgue@web.de wrote:
>
> Benjamin Goldberg wrote:
> > I'm not sure what you mean, when you say that you aren't able to
> > synchronize on the one socket... You obtain a lock, write to the
> > socket, then release the lock. Since the data which you intend to
> > write was produced before the lock was obtained, very little time is
> > spent obtaining and holding onto the lock -- thus, the child process
> > is not blocked for very long.
>
> Problem is: the program sends a request to the server and waits for
> an answer ... and the server might spend several minutes before
> coming back. So the other process is locked out as long as the server
> needs to process the request.
No, I didn't say, keep the lock until you get a response. I said, keep
the lock until you've written all of your data to the socket. Not the
same thing.
> As I said: the child process has to control some environment things
> (like regulating the temperature of hardware components). And it is a
> very bad idea to postpone a request like "temp xxx is way to high; do
> something about it" for 10 minutes because the child process is
> blocked by the main process.
Fortunatly, writing data to a socket almost never blocks.
> The flaw was already part of the design my mind: we have to do things
> in parallel - so it was a bad idea to create only a unique resource
> for that task. Time to fix that.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 6 Nov 2002 11:48:01 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How much faster is dbm over MySQL
Message-Id: <slrnasileh.bem.tadmc@magna.augustmail.com>
djf <djf@gxn.net> wrote:
> dbm's are not a relational database -
Yes they are.
They are not a Relational Database Management System though,
which is what I expect you meant when you said "relational database".
> merely a key/value type storage.
A hash is a relational database that is limited to only one relation.
> I suppose if you was to have said dbm/hash style it might have been remotely
> OT, but hey
Nice try getting it back on-topic, but it didn't work :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 06 Nov 2002 14:08:49 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <3DC968C1.7060009@thecouch.homeip.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Joe Moschak wrote:
| Every time I invoke a perl script from a web page, I get a different
process
| ID (PID) and consequently different values for any variables. How can I
| make it so that each time I invoke my script from a given web session
I get
| the same PID instead of a different one? Below is code I use to
verify that
| I get different PIDs each time.
I think you're misunderstanding what a PID is.
In the world of server-side web scripting, there is something called
"sessions". A session is the server's attempt at tracking an invididual
user for the duration of their visit. This can be done by the web
server software itself (Apache/IIS/etc) or by the CGI code itself (your
perl script). It's method of implementation is different, some use
client-side cookies, some use IP addresses, etc... If sessions are set
up right, you will get the same session ID for all invocations.
PIDs (Process IDs), however, have nothing to do with the web server or
your perl script. PIDs happen on the Operating System level. Every
time a new process starts, the operating system gives it a new, unique
PID. PIDs are how your operating system distinguishes between different
processes.
When your web server wants to run your CGI, it runs a new perl process,
therefore getting a new PID.
As a matter of fact, people often use the PID + time as a method to come
up with a unique number. You're trying to do the exact opposite, which
is the wrong way to go about it.
My advice is to look into "sessions". CPAN seems to have a handful of
modules at http://search.cpan.org/search?query=session&mode=all
Best of luck.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9yWjBeS99pGMif6wRAssjAKDat0M+sfC01xFvoZvll+tv0oE/jgCg4Zry
ZwFGGfpTHC/EEUma+6NgJ7w=
=57tY
-----END PGP SIGNATURE-----
------------------------------
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 4074
***************************************