[17232] in Perl-Users-Digest
Perl-Users Digest, Issue: 4654 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 18 18:06:22 2000
Date: Wed, 18 Oct 2000 15:05:21 -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: <971906720-v9-i4654@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 18 Oct 2000 Volume: 9 Number: 4654
Today's topics:
Re: A Simpler perlish way <ddjones@speakeasy.org>
Re: A Simpler perlish way (Logan Shaw)
ADO/ Access DB question <lancec@verinet.com>
Re: ADO/ Access DB question <bkennedy@hmsonline.com>
Re: amazing surftips <gellyfish@gellyfish.com>
Re: Backup and email a file. My head is spinning! <peter.sundstrom@eds.com>
Re: BrowseForFolder in Win32::FileOp <urs.grendelmeier@svema.ch>
Re: Can prospective employer legally obtain your presen <gellyfish@gellyfish.com>
Re: Can someone help with this scrip? Sytax error! <gellyfish@gellyfish.com>
Case Statement? (JoeCoolCols)
Re: Case Statement? <russ_jones@rac.ray.com>
Re: Case Statement? <jeff@vpservices.com>
Re: CGI-script to act as a proxy <godzilla@stomp.stomp.tokyo>
Re: CGI-script to act as a proxy </michael>
Re: CGI-script to act as a proxy (Randal L. Schwartz)
Re: converting a binary file to ascii <lr@hpl.hp.com>
Re: converting a binary file to ascii (John Stanley)
Re: Date Arithmetic - how???? (Mark Wright)
Re: executing UNIX-commands on remote systems (mailq) <anders@wall.alweb.dk>
Re: factorial function problem (Matthew Zimmerman)
Re: factorial function problem (Tramm Hudson)
Help w/ non-blocking waitpid on Windows <tom.mccurdy@mindspring.com>
Re: How to send HTML over sendmail??? <peter.sundstrom@eds.com>
Re: IO::File or FileHandle - which? <uri@sysarch.com>
Re: Make this regex neater, anyone? (Craig Berry)
metacharacters pepite@hotmail.com
Re: metacharacters <anders@wall.alweb.dk>
PERL IIS help (Hou-Gee Michael Wong)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Oct 2000 21:19:52 GMT
From: Daniel Jones <ddjones@speakeasy.org>
Subject: Re: A Simpler perlish way
Message-Id: <6a5suso3ud2p49sqstem6udrab5ehp9676@4ax.com>
On Wed, 18 Oct 2000 10:55:04 +0100, Nick Condon
<nickco3@yahoo.co.uk> wrote:
>"Godzilla!" wrote:
>
>> I am one of those who looks at a wheel and thinks,
>>
>> "There is probably a better way to do this."
>
>What have you come up with?
Levitation. Concept is great. Implementation is still a
little fuzzy, though.
------------------------------
Date: 18 Oct 2000 16:50:26 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: A Simpler perlish way
Message-Id: <8sl5v2$6jm$1@provolone.cs.utexas.edu>
In article <6a5suso3ud2p49sqstem6udrab5ehp9676@4ax.com>,
Daniel Jones <ddjones@speakeasy.org> wrote:
>On Wed, 18 Oct 2000 10:55:04 +0100, Nick Condon
><nickco3@yahoo.co.uk> wrote:
>>"Godzilla!" wrote:
>>> I am one of those who looks at a wheel and thinks,
>>>
>>> "There is probably a better way to do this."
>>
>>What have you come up with?
>
>Levitation. Concept is great. Implementation is still a
>little fuzzy, though.
I don't know, some trains seem to be utilizing this concept just fine.
Side note (as if this were on topic to begin with): I went to
http://www.mvp.de/ to look at some maglev train info, but it
was in German, so I had http://babelfish.altavista.com/ translate
it to English. Part of it reads,
Loves homepage visitors and rapidly fanfan rapidly
fan, we are unfortunately written off for this year!
Usually I am able to decipher the output of automated tranlators,
but not in this case...
- Logan
------------------------------
Date: Wed, 18 Oct 2000 12:43:38 -0600
From: "lance celli" <lancec@verinet.com>
Subject: ADO/ Access DB question
Message-Id: <8skr1t$d7a$1@fcnews.fc.hp.com>
I want to add a record to a recordset via perl. Here's what I have:
use OLE;
my $conn = CreateObject OLE "ADODB.Connection" || die "CreateObject: $!";
$conn->Open('odbc_wombat');
my $sql = "SELECT * FROM Tasks";
my $rs = $conn->Execute($sql);
my @Fields = qw(taskName Start End Status phaseID);
my @Values = ("Test Entry","10/30/00","11/5/00","Not Started","3");
$rs->AddNew(@Fields, @Values);
$rs->Update();
$rs->Close();
$conn->Close();
This code produces no errors, but doesn't add anything to the database. I
can read from the DB but can't change anything. It's an access db by the
way. Any tips on how to add/modify entries in a table via perl? Thanks.
------------------------------
Date: Wed, 18 Oct 2000 20:33:27 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: ADO/ Access DB question
Message-Id: <rOnH5.56279$td5.8464239@news1.rdc2.pa.home.com>
"lance celli" <lancec@verinet.com> wrote in message
news:8skr1t$d7a$1@fcnews.fc.hp.com...
> I want to add a record to a recordset via perl. Here's what I have:
>
> use OLE;
>
> my $conn = CreateObject OLE "ADODB.Connection" || die "CreateObject: $!";
> $conn->Open('odbc_wombat');
> my $sql = "SELECT * FROM Tasks";
> my $rs = $conn->Execute($sql);
> This code produces no errors, but doesn't add anything to the database. I
> can read from the DB but can't change anything. It's an access db by the
> way. Any tips on how to add/modify entries in a table via perl? Thanks.
I believe that creating the recordset object this way will result in ADO
using the default parameters, which are read only. Try creating the
recordset object explicitly:
my $recordset = CreateObject OLE "ADODB.RecordSet";
$recordset->Open("SELECT * FROM Tasks",$conn, 2, 2);
The numbers are constants, the first is adOpenDynamic and the second is the
lock type adLockPessimistic which should allow updates - the defaults to the
open method for the RecordSet object are are adForwardOnly and
adLockReadOnly, so I imagine they are automatically used with the execute
method of the Connection object. You can get these constants with
Win32::ADO or Win32::OLE::Const. Hope this helps--
--Ben Kennedy
------------------------------
Date: 18 Oct 2000 07:16:42 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: amazing surftips
Message-Id: <8sjf8a$a1m$1@orpheus.gellyfish.com>
On Tue, 17 Oct 2000 20:33:30 +0200 fReEsTyLeR xx wrote:
> Hi,
> find out the two most exiting pages in the hole internet:
>
> http://www.xxxxxxx.com
> Here you can buy a piece of the moon !!!
>
But my boss wants the whole moon and on a stick too.
Forwarded to abuse@komtel.net
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Thu, 19 Oct 2000 09:48:27 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Backup and email a file. My head is spinning!
Message-Id: <8sl2hk$4jn$1@hermes.nz.eds.com>
John MacLeod <john@macleodweb.com> wrote in message
news:8sj9110gut@enews3.newsguy.com...
> My head is spinning! Could someone please help with this seemingly simple
> task?
>
> I want to set up a cron job to...
>
> 1. Backup a txt file (formresults.txt).
> 2. Email the formresults.txt file to an external email address
> (client@hisdomain.com) each night at 3 am.
>
> The file is located at...
> /usr/www/users/myaccount/client/formresults.txt
>
> Any help would be GREATLY appreciated.
Did you really want/need to do this in Perl?
0 3 * * * cp formresults.txt formresults.bak; mail someone@foo.com
<formresults.txt
------------------------------
Date: Wed, 18 Oct 2000 22:02:53 +0200
From: "news.hitline.ch" <urs.grendelmeier@svema.ch>
Subject: Re: BrowseForFolder in Win32::FileOp
Message-Id: <8skvgu$qlf$1@pollux.ip-plus.net>
I still have the same problem.
"Urs Grendelmeier" <ursgrendelmeier@chestonag.ch> schrieb im Newsbeitrag
news:8sestf$gfk$1@pollux.ip-plus.net...
> Hi,
> BrowseForFolder in Win32::FileOp doesn't work with ActivPerl 618. Is there
a
> workaround or an other solution (Tk?) or has anyone the same problems?
>
> greetings
> Grendi
>
>
------------------------------
Date: 18 Oct 2000 07:39:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Can prospective employer legally obtain your present salary?
Message-Id: <8sjgjq$a39$1@orpheus.gellyfish.com>
In comp.lang.perl.misc xochizen@my-deja.com wrote:
>
>
> (Perl folk, you, we, are world-renowned for our bullshit-detecting
> abilities, which is why I've also posted this to comp.lang.perl.misc)
>
Whether or not the renown is accurate is immaterial, it is still not
an even remotely appropriate topic for comp.lang.perl.misc .
Followups trimmed.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 18 Oct 2000 07:11:04 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Can someone help with this scrip? Sytax error!
Message-Id: <8sjeto$a16$1@orpheus.gellyfish.com>
On Tue, 17 Oct 2000 19:48:12 +0000 Richard Morris wrote:
>
> Sorry, Newbie here.
>
> I have a script and when run, gives the message:
>
> [root@qube rdm3]# perl massadd.pl list
> syntax error at massadd.pl line 31, near "= ) "
kick yourself now :
> }
> while ($line = ) {
^ Missing something or other
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 18 Oct 2000 21:11:40 GMT
From: joecoolcols@aol.com (JoeCoolCols)
Subject: Case Statement?
Message-Id: <20001018171140.03927.00000267@ng-cn1.aol.com>
Is there anything like a Case Statement in Perl or do I
have to use multiple if else ifs? seems like this would
slow things down. There are 132 questions to pick from
to make a custom form and I'm checking which ones
the user has picked. Beside can Perl nest that deep?
Please send answers to joecoolcols@aol.com and
post. I have a hard time finding replies here.
Thanks,
Joe
If pick = 1
Write question1 to form
else if pick = 2
Write question2 to form
.
.
.
.
.
else write question132 to form
------------------------------
Date: Wed, 18 Oct 2000 16:16:54 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Case Statement?
Message-Id: <39EE1346.C393DA5B@rac.ray.com>
JoeCoolCols wrote:
>
> Is there anything like a Case Statement in Perl
perldoc -q case
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: Wed, 18 Oct 2000 14:20:33 -0700
From: Jeff Zucker <jeff@vpservices.com>
To: JoeCoolCols <joecoolcols@aol.com>
Subject: Re: Case Statement?
Message-Id: <39EE1421.D35B2C2D@vpservices.com>
JoeCoolCols wrote:
>
> Is there anything like a Case Statement
perldoc -q case
Also see the Switch.pm module from Damian Conway.
> Please send answers to joecoolcols@aol.com and
> post. I have a hard time finding replies here.
Well, ok this first time, but from now on, if you post here, read here.
Usenet is a community resource, not a private help desk.
> If pick = 1
> Write question1 to form
> else if pick = 2
> Write question2 to form
> ...
> else write question132 to form
That doesn't require a case statement, it requires a hash:
my %question = (
1 => 'What color is an orange?',
2 => 'Where do they make swiss cheese?',
# ...
132 => 'Is this the last question?',
);
my $pick = 1;
print $question{$pick}; # prints 'What color is an orange?'
--
Jeff
------------------------------
Date: Wed, 18 Oct 2000 11:24:48 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: CGI-script to act as a proxy
Message-Id: <39EDEAF0.F5B41D4E@stomp.stomp.tokyo>
Russ Jones wrote:
> Mark Kuin wrote:
> > julesgr wrote:
> > > At my girlfriend's work, they are using a proxy which prevents her from
> > > accessing certain websites, including mail.yahoo.com.
> > A cleverer way is asking your girlfriend to switch jobs.
> Or perhaps suggesting that your girlfriend do her work at work and
> read her personal email at home, since that appears to be what her
> company intends.
> Russ Jones - HP OpenView IT/Operatons support
> Raytheon Aircraft Company, Wichita KS
> russ_jones@rac.ray.com 316-676-0747
My presumption is, Mr. Jones, you are at home
rather than at work.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Wed, 18 Oct 2000 14:39:19 -0400
From: </michael>
Subject: Re: CGI-script to act as a proxy
Message-Id: <gfrrus845q43bi1qcf62aff40ebeaqenic@4ax.com>
On Wed, 18 Oct 2000 10:18:20 GMT, julesgr@my-deja.com wrote:
>Dear All,
>
>At my girlfriend's work, they are using a proxy which prevents her from
>accessing certain websites, including mail.yahoo.com. I would like to
>set up my computer (my1.computer.com, we'll call it), which is
>accessible to her, as a sort of secondary proxy to get round this
>restriction. What I need is a cgi script (let's call it proxyparser)
>which is invoked by her request:
>http://my1.computer.com/cgi-bin/proxyparser?http://mail.yahoo.com. The
>script requests the page from mail.yahoo.com, parses it to change all
>the links within it to "http://my1.computer.com/cgi-bin/proxyparser?"
>followed by the link, and then sends this page back to my girlfriend. It
>would also have to deal with cookies.
>
>Does anyone know of such a script or a cleverer way of doing this?
>Best wishes,
>Jules
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
CGIProxy 1.3 (released April 8, 2000)
HTTP/FTP Proxy in a CGI Script
(c) 1996, 1998-2000 by James Marshall
For the latest, see http://www.jmarshall.com/tools/cgiproxy/
Here you go.. There probably a newer version at the above address.
Michael
------------------------------
Date: 18 Oct 2000 13:10:38 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: CGI-script to act as a proxy
Message-Id: <m1og0huczl.fsf@halfdome.holdit.com>
>>>>> "slash_something" == <michael> writes:
slash_something> CGIProxy 1.3 (released April 8, 2000)
slash_something> HTTP/FTP Proxy in a CGI Script
slash_something> (c) 1996, 1998-2000 by James Marshall
For a different implementation, check out
<http://www.stonehenge.com/merlyn/WebTechniques/col32.html>
Which I would probably rewrite now to use HTML::Parser v3 API, but will
still work just fine.
--
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: Wed, 18 Oct 2000 11:25:59 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: converting a binary file to ascii
Message-Id: <MPG.14578b0d74e2d86098ae45@nntp.hpl.hp.com>
[In the future, please quote selectively and place your responses after
what you are quoting, as I have done here. This makes the discussion
easier to follow, and is the policy of this and most other newsgroups.]
In article <39EDD9C8.8373E95A@pauls.seanet.com> on Wed, 18 Oct 2000
10:11:36 -0700, Paul Spitalny <pauls_spam_no@pauls.seanet.com> says...
> Larry Rosler wrote:
> > In article <39ECE20B.437EB4BC@pauls.seanet.com>,
> > pauls_spam_no@pauls.seanet.com says...
> >
> > ...
> >
> > > See how the last number on the right column is screwed-up, but
> > > everything before that looks fine?? What gives?? Here's how I did it,
> > > perhaps you folks can find the error in my ways (I know, I know, i
> > > didn't check if the file exists before opening it)
> > >
> > > open(NEW,'<bin_only.dat');
> > > open(OUT,'>thebin.dat');
> > > binmode NEW;
...
> > The only thing that comes to mind is that you read fewer than 8 bytes
> > the last time through the loop.
> >
> > Check the size of the input file for divisibility by 8, and check the
> > number of bytes read to be 8 instead of the simple Boolean test in your
> > code.
>
> This sample output I showed in one of last emails did not include the rest
> of the output. Basically, all the numbers pastr a certain point are
> incorrect and think it has something to do with what happenswhen the end
> of a line in the binary file is encountered. This sounds similar to what
> Larry is suggesting.
I don't think so.
Apparently your input file has 8-byte alignment screwed up. If this is
due to a "\12" in the binary data, it can only be because the file was
*written* as a text file, so what was written was really "\15\12".
To verify this conjectore, test again without the (correct) 'binmode
NEW;' statement. Then any "\15\12" sequence in the input file will be
converted (back?) to "\12" and the program should work.
If this is correct, then make sure that in the future the binary file is
written properly, using binmode() or its C equivalent,
fp = fopen(filename, "wb");
You might find unpacking the file with 'H*' format a useful way of
seeing what is really there.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 18 Oct 2000 19:04:39 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: converting a binary file to ascii
Message-Id: <8sks87$33$1@news.NERO.NET>
In article <39EDD9C8.8373E95A@pauls.seanet.com>,
Paul Spitalny <pauls@pauls.-nospam-seanet.com> wrote:
>Hi Larry, et al,
>This sample output I showed in one of last emails did not include the rest
>of the output. Basically, all the numbers pastr a certain point are
>incorrect and think it has something to do with what happenswhen the end
>of a line in the binary file is encountered. This sounds similar to what
>Larry is suggesting.
There are no lines in binary files. There may be "records". Records are
not "lines".
There may be non-float data stored in your binary file. We don't know
that since we don't know the format for your file.
There may also be garbage in the file, if you transferred the binary
file via FTP in ASCII mode to or from a system which differentiates
ASCII and IMAGE file types.
And stop putting your resonse before what you are responding to.
------------------------------
Date: Wed, 18 Oct 2000 18:14:10 GMT
From: mark@giallo.demon.nul (Mark Wright)
Subject: Re: Date Arithmetic - how????
Message-Id: <39ede7c5.13564733@194.159.73.10>
One joyful day (18 Oct 2000 15:20:19 +0100 to be precise), Edward Avis
<epa98@doc.ic.ac.uk> decided that the Usenet community would benefit
from this remarkable comment:
>I recommend Date::Manip. It does everything you'd want to do with
>dates.
And I bet it's a lot cheaper too.
Mark Wright
- mark@giallo.demon.nl
--
perl -e "print join' '=>map{$_ if s/(\w*)(.)ay/\U$2\E$1/}grep/^\w/=>reverse qw+ackerhay :o( erlpay :o| notheraay :o\ ustjay :o)+"
------------------------------
Date: Wed, 18 Oct 2000 20:44:37 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: executing UNIX-commands on remote systems (mailq)
Message-Id: <8dmH5.6532$Uy5.203250@news000.worldonline.dk>
Karsten Perlich wrote:
> Hi folks,
>
> I want to monitor the mail-queue of a remote system. to see how long the
> mailq is, something like the response of "mailq | head -1 | cut -f2
> -d'(' | cut -f1 -d' '" should be executed on the romote-system and the
> result end in a variable of my local perl-script.
>
> Thanks for any (quick) help
>
> Karsten
>
put the script on the remote machine and callit from your browser, or using
LWP
If you were able to execute a command on a remote machine, it would be a
bit unsafe, wouldn't it??
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 18 Oct 2000 20:33:18 GMT
From: mdz4c@node3.unix.Virginia.EDU (Matthew Zimmerman)
Subject: Re: factorial function problem
Message-Id: <8sl1ee$4ns$1@murdoch.acc.Virginia.EDU>
In article <87vgv5fxal.fsf@limey.hpcc.uh.edu>,
Tony Curtis <tony_curtis32@yahoo.com> wrote:
>>> On Fri, 06 Oct 2000 16:33:40 GMT,
>>> iamnotananimal@my-deja.com said:
>>
>> factorial();
>
>you're not passing $n to the sub.
Not to mention that that should be
print factorial($n);
since the function only returns the value, and doesn't print it.
--
--
|Matthew Zimmerman http://www.people.virginia.edu/~mdz4c |
|Interdisciplinary Biophysics Program |"I AM serious. |
|University of Virginia | And stop calling me Shirley."|
------------------------------
Date: 18 Oct 2000 21:40:14 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: factorial function problem
Message-Id: <8sl5bu$5b2$1@sloth.swcp.com>
Keywords: misleading troll, functional style, closure abuse
[posted and cc'd to cited author]
Tony Curtis <tony_curtis32@yahoo.com> wrote:
> #!/usr/bin/perl -w
> use strict;
Always good advice.
> > print "Number?"; $n = <STDIN>;
>
> You need to chomp() $n to get rid of the newline:
>
> chomp($n = <STDIN>);
That is not actually required. Trailing whitespace will be discarded,
without even a warning being emitted.
> ... Note also that you can improve the time performance of
> factorial() by memoizing the call (at the expense of
> cacheing previous results and using a bit more space).
>
> use Memoize;
> memoize('factorial');
Or, something similar to what was discussed in
http://www.deja.com/=dnc/getdoc.xp?AN=503823326
with the change to memoize the results as they are computed:
#!/usr/bin/perl -w
use strict;
my $f = sub {
my $a = shift;
my @v = qw/0 1/;
sub { $a->( $a, my $n = shift, \@v ) }
}->( sub {
my $n = $_[1]--;
push @{$_[2]}, $n * $_[0]->(@_) if @{$_[2]} <= $n;
$_[2]->[$n];
} );
print "9! = ", $f->(9), "\n";
print "3! = ", $f->(3), "\n";
__END__
There, isn't that easier? It properly uses lexical variables
for the recursion, is -w and strict clean and now memoizes the
results. What else could you want?
Trollingly yours,
Tramm
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
Date: Wed, 18 Oct 2000 15:08:25 -0400
From: Tom McCurdy <tom.mccurdy@mindspring.com>
Subject: Help w/ non-blocking waitpid on Windows
Message-Id: <39EDF528.827BE900@mindspring.com>
I'm trying to use the non-blocking form of waitpid in my script but
under Windows it doesn't seem to behave as expected. The code snippet
below waits for each child to complete before forking another child.
The code works as expected under Linux.
I expect that the parent will execute most of its print statements
before the child processes begin to print (because of the sleep
statement), which is the case if you comment out the waitpid statement.
Unfortunately the Windows version of perl doesn't do auto-reclaimation
of process handles and will stop forking at 64.
I've tested the code on ActiveState Perl v 5.6 on Windows 95 (build 617)
and Windows 2000 (build 618). Also, the pseudo pids that are generated
using the Windows perl fork are negative. Is that odd and counter to the
documentation?
Has anyone gotten this to work on Windows?
Thanks for any help,
Tom McCurdy
Code below
-----------------------------------------------
use POSIX ":sys_wait_h";
for ($i=1; $i<=66; $i++)
{
FORK: {
if ($fpid = fork()) { # Fork, Any parent processing in here
print "I'm the parent and I just forked $i, fpid = $fpid.\n";
}
elsif (defined $fpid) { # fpid should be zero if defined
(child proc)
sleep 2;
print "I'm the child and I just got forked - i = $i, fpid =
$$.\n";
exit (0); # Child finishes execution here
}
else { # Fork error
print STDERR "ERROR: Problem forking: $!. when i = $i.\n";
}
} # end FORK
waitpid (-1, &WNOHANG); # Should be non-blocking waitpid
} # end for i loop
------------------------------
Date: Thu, 19 Oct 2000 10:02:01 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: How to send HTML over sendmail???
Message-Id: <8sl3b1$62o$1@hermes.nz.eds.com>
Gene <gene@allsysinc.com> wrote in message
news:eWiH5.3407$NP.197781@news.flash.net...
>
> Here's some clips of what I've used in the past that worked pretty good.
It
> might be simpler if you just want to send HTML, but I don't know. This
code
> was partly from some other script that I downloaded somewhere, and partly
> from an Outlook Express email. It might be more complicated than you need,
> as I was using it to send attachments as well. I'm no expert in the email
> standards, but I do know this works. Also, I know that tons of you on this
> group love to pick apart everyone else's code, so go ahead. I'm not
claiming
> to be an expert, but this works for me and has for the last couple of
years,
> and it is used almost daily.
> Good Luck
>
> -gene
>
>
> ####all the header info goes here...the to, from, etc.
> <snip>
> print MAIL "Subject: $subject\n"; ##replace $subject with your
subject,
> of course
>
> # define message type as multipart:
> print MAIL "MIME-Version: 1.0\n";
> print MAIL "Content-Type: multipart/mixed;
> boundary=\"------------26A28E87DBB\"\n\n";
> print MAIL "This is a multi-part message in MIME format.\n\n";
> print MAIL "--------------26A28E87DBB\n";
>
> print MAIL "Content-Type: multipart/alternative;\n";
> print MAIL "
> boundary=\"----=_NextPart_000_0035_01BEDA77.7D452740\"\n\n";
> print MAIL "------=_NextPart_000_0035_01BEDA77.7D452740\n";
> print MAIL "Content-Type: text/plain;\n";
> print MAIL " charset=\"iso-8859-1\"\n";
> print MAIL "Content-Transfer-Encoding: quoted-printable\n\n";
>
> #### the text version of your message goes here
> <snip>
>
>
> print MAIL "------=_NextPart_000_0035_01BEDA77.7D452740\n";
> print MAIL "Content-Type: text/html;\n";
> print MAIL " charset=\"iso-8859-1\"\n";
> print MAIL "Content-Transfer-Encoding: quoted-printable\n\n";
>
> #### the html version goes here.
> <snip>
>
> print MAIL "------=_NextPart_000_0035_01BEDA77.7D452740--\n\n";
>
> #### this is where i attached the files, if there were any
>
> <snip>
> print MAIL "--------------26A28E87DBB--\n";
> close MAIL;
Or you could simplify the whole lot with MIME::Lite
use MIME::Lite
my $msg = MIME::Lite->new(
To =>'you@yourhost.com',
Subject =>'$subject',
Type =>'multipart/related'
);
$msg->attach(Type => 'text/plain',
Path => '/path/to/somefile.txt',
);
$msg->attach(Type => 'text/html',
path => /path/to/somefile.html':
);
$msg->send();
------------------------------
Date: Wed, 18 Oct 2000 20:04:34 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: IO::File or FileHandle - which?
Message-Id: <x78zrlsyp8.fsf@home.sysarch.com>
>>>>> "RM" == Ren Maddox <ren.maddox@tivoli.com> writes:
RM> Uri Guttman <uri@sysarch.com> writes:
>>
>> is that clear?
RM> I think so, but I'm not sure how it is different from what I said...?
well, the OP seemed to understand what i wrote as he emailed me about
it.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Wed, 18 Oct 2000 18:31:32 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Make this regex neater, anyone?
Message-Id: <surr44ral4mv30@corp.supernews.com>
Philip Lees (pjlees@ics.forthcomingevents.gr) wrote:
: > $lastNonDigits = ($str =~ m/\D+/g)[-1];
:
: Thanks, Craig. That's neat. Could you explain the significance of the
: [-1] to this learner? I can't find any mention of that syntax in
: perlre.
That's because it doesn't have anything to do with regexes. :) First,
consider that a /g match in list context (like the one in my code above)
produces a list of all matches. In this case, this will be a list of all
the sequences of non-digits which appear in $str.
This list can be indexed into like any other list. Perl provides an
incredibly handy bit of semantics which interprets negative array indices
as being offsets from the *end* of the list, so $a[-1] is the last
element in @a, $a[-5] is the fifth-from-the-last element, and so forth.
So the [-1] index above indexes the last matched string of non-digits --
which is what you wanted.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Quidquid latine dictum sit, altum viditur."
|
------------------------------
Date: Wed, 18 Oct 2000 18:06:03 GMT
From: pepite@hotmail.com
Subject: metacharacters
Message-Id: <8skoq4$7ht$1@nnrp1.deja.com>
Can someone tell me what the synatx is for
validating that my string has uppercase letters from A-Z exluding for
example H and J and R and S and whatever else there are about 7 or 8
letters I want to excluse.
The Variable would be
$variable
and it would contain something like this J7:Y7:Q7:B7:H7:M7:N7:V7:K7:L7
please reply to pepite@hotmail.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 18 Oct 2000 20:46:27 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: metacharacters
Message-Id: <SemH5.6533$Uy5.203296@news000.worldonline.dk>
pepite@hotmail.com wrote:
> Can someone tell me what the synatx is for
> validating that my string has uppercase letters from A-Z exluding for
> example H and J and R and S and whatever else there are about 7 or 8
> letters I want to excluse.
perldoc perlre
> The Variable would be
> $variable
> and it would contain something like this J7:Y7:Q7:B7:H7:M7:N7:V7:K7:L7
>
> please reply to pepite@hotmail.com
>
No.
you ask here, and come here for oyur answers.
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 18 Oct 2000 20:56:31 GMT
From: hougee@sfu.ca (Hou-Gee Michael Wong)
Subject: PERL IIS help
Message-Id: <8sl2pv$5lj$1@morgoth.sfu.ca>
Keywords: PERL IIS .pm
Hi all,
Here's the problem...
I'm trying to use a perl library (.pm) in my perl cgi scripts under IIS and it's returning
me with a can't locate xxxxxx.pm in @INC error.
I have my perl scripts and the .pm file both sitting in a sub folder under the physical
location of the web root (c:\inetpub\wwwroot\subfolder). When the script executes,
instead of looking for the .pm file in the same directory of the script, it looks for the
.pm file in the web root c:\inetpub\wwwroot.
I know there's a way out of this but I just can't find how.
any suggestion will be greatly appreciated
Michael Wong
hougee@sfu.ca
--
Michael Wong
hougee@sfu.ca
------------------------------
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 4654
**************************************