[12125] in Perl-Users-Digest
Perl-Users Digest, Issue: 5724 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 19 13:07:21 1999
Date: Wed, 19 May 99 10:00:27 -0700
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, 19 May 1999 Volume: 8 Number: 5724
Today's topics:
Re: _Please_ improve localtime! (Larry Rosler)
Re: _Please_ improve localtime! <gellyfish@gellyfish.com>
Re: Accents Sensitivity <cassell@mail.cor.epa.gov>
Re: An /e for a match rather than a substitution (Larry Rosler)
Re: An /e for a match rather than a substitution <steven.peter.primrose-smith@avl.com>
Re: An /e for a match rather than a substitution (Larry Rosler)
Re: best way to database stuff using Perl? <jhecker@iago.nac.net>
C superior to Perl in DB2 programming? <tzadikv@my-dejanews.com>
Changing format of (long!) flat text file to make searc <eduardo@sistelnet.es>
Re: evalling __END__ and <DATA> <swarren@www.wwwdotorg.org>
Re: FAQ 4.41: How do I compute the difference of two ar (M.J.T. Guy)
Re: FAQ 4.68: How do I handle binary data correctly? (Larry Rosler)
Re: fetching specific info from a text file <swarren@www.wwwdotorg.org>
Re: File locks don't. (Chris Nandor)
Re: File locks don't. <s1dugan@nospam.exnet.iastate.edu>
Re: File locks don't. (Chris Nandor)
Re: fork() it OVER!! (soybean)
Re: fork() it OVER!! <dms@rtp-bosch.com>
Help with 'unlink'ing files <winfieldh@mindspring.com>
Re: Help with 'unlink'ing files (David Cantrell)
Re: Help with 'unlink'ing files (Greg Bacon)
HELP: Internet Module rslifka@my-dejanews.com
HELP: Perl Internet (HTTP->Request()) rslifka@my-dejanews.com
Re: Help: Win32::Registry (Michel Dalle)
Re: How can I skip the "." and ".." files when reading <gellyfish@gellyfish.com>
Re: How to access a https site mjzanghi@my-dejanews.com
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 May 1999 08:51:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: _Please_ improve localtime!
Message-Id: <MPG.11ac7dc8fa8b9d5a989aa5@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7huh55$lks@llama.swcp.com> on 19 May 1999 08:17:09 -0600,
Tramm Hudson <hudson@swcp.com> says...
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> [snip]
> > And the documentation for localtime C function says:
> >
> > Declarations of all the functions and externals, and the tm structure,
> > are in the <time.h> header file. The structure declaration is:
> >
> > struct tm {
> > int tm_sec; /* seconds after the minute - [0, 59] */
>
> To be pedantic, this field actually has the range of 0..60 inclusive.
> Leap seconds do occur and some of our time sources reflect this.
Some of the earlier C documentation had [0, 61], on the thoroughly wrong
notion that UTC could leap by two seconds at once.
It is surprising that any time sources reflect leap seconds at all.
They are ignored in the Unix-epoch time scale, because they add
unwarranted complexity to interval calculations. So I would stick with
0..59.
> [snip]
> > long tm_tzadj; /* seconds from GMT (east < 0) */
>
> I've always thought this was backwards. Japan is GMT+9:00, but the TZ
> variable must be set to "JST -9:00". Grrr.
Just plain old North-America-centrism. Of course it's backwards, but
not changeable now. The document should say 'seconds to GMT'. :-)
For the record, neither of the last two fields quoted by Jonathan Stowe:
long tm_tzadj; /* seconds from GMT (east < 0) */
char tm_name[LTZNMAX]; /* name of timezone */
are in the ANSI/ISO C Standard definition of localtime(), so they are
not in Perl's definition either.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 19 May 1999 17:22:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: _Please_ improve localtime!
Message-Id: <3742e53f@newsread3.dircon.co.uk>
Larry Rosler <lr@hpl.hp.com> wrote:
> [Posted and a courtesy copy sent.]
>
> In article <7huh55$lks@llama.swcp.com> on 19 May 1999 08:17:09 -0600,
> Tramm Hudson <hudson@swcp.com> says...
>> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>> [snip]
>> > And the documentation for localtime C function says:
>> >
>> > Declarations of all the functions and externals, and the tm structure,
>> > are in the <time.h> header file. The structure declaration is:
>> >
>> > struct tm {
>> > int tm_sec; /* seconds after the minute - [0, 59] */
>>
>> To be pedantic, this field actually has the range of 0..60 inclusive.
>> Leap seconds do occur and some of our time sources reflect this.
>
> Some of the earlier C documentation had [0, 61], on the thoroughly wrong
> notion that UTC could leap by two seconds at once.
>
> It is surprising that any time sources reflect leap seconds at all.
> They are ignored in the Unix-epoch time scale, because they add
> unwarranted complexity to interval calculations. So I would stick with
> 0..59.
>
>> [snip]
>> > long tm_tzadj; /* seconds from GMT (east < 0) */
>>
>> I've always thought this was backwards. Japan is GMT+9:00, but the TZ
>> variable must be set to "JST -9:00". Grrr.
>
> Just plain old North-America-centrism. Of course it's backwards, but
> not changeable now. The document should say 'seconds to GMT'. :-)
>
> For the record, neither of the last two fields quoted by Jonathan Stowe:
>
> long tm_tzadj; /* seconds from GMT (east < 0) */
> char tm_name[LTZNMAX]; /* name of timezone */
>
> are in the ANSI/ISO C Standard definition of localtime(), so they are
> not in Perl's definition either.
>
Er yes this is SCO Unix:
System = figment
Node = figment
Release = 3.2v4.2
KernelID = 93/04/28
Machine = i80486
BusType = ISA
Serial = ltd001605
Users = unlim
OEM# = 0
Origin# = 1
I must admit I didnt even notice that - I just typed 'man localtime' into
the first spare telnet I could find ;-O How was I to know it was the oldest
machine in the place ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Wed, 19 May 1999 09:41:20 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Accents Sensitivity
Message-Id: <3742E9B0.E59CA6AA@mail.cor.epa.gov>
Jonathan Stowe wrote:
>
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> > Yogish Baliga wrote:
> >>
> >> You can use Phoenetic searching using the soundex function.
> >>
> >> -- Baliga
> >>
> >> amenrique@my-dejanews.com wrote:
> >>
> >> > I have developed a search engine in Spanish. It works fine. The problem
> >> > is that users are trying to find words without writing the accents used
> >> > in spanish, i.e. they search for Maria with no results, as the right
> >> > spelling is Marma (with an accent on the i)
> >
> > That may help. But soundex() hashes everything into a teeny
> > space, leading to unfortunate collisions. Try checking
> > the soundex values of 'Ellery' and 'Euler'. They're the
> > same. Probably not what the poster wanted.
> >
>
> Also the Text::Soundex module will be optimized for English speakers or
> as the manpage puts it:
>
> The algorithm is intended to hash words (in particular surnames) into a
> small space using a simple model which approximates the sound of the word
> when spoken by an English speaker
>
> Of course there is no reason that it cant be modified to work with Spanish
> names (actually I'd be surprised if there isnt a similar algorithm out
> there already)
You're right. When I answered, I was only thinking about the
posed example. Since Text::Soundex elides the vowels after the
initial letter, I neglected:
[1] initial letters which are accented vowels
[2] non-vowels such as n-with-tilde [stupid newsreader, I can't
write the letter here].
And last month there was that guy looking for 'soundex' for
Latin. You think he's finished programming yet?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 08:15:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: An /e for a match rather than a substitution
Message-Id: <MPG.11ac7578bb97e3d4989aa4@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7hug34$1qh@fstgal00.tu-graz.ac.at> on Wed, 19 May 1999
15:58:58 +0100, Steven Primrose-Smith <steven.peter.primrose-
smith@avl.com> says...
> If I want to evaluate the right side of a substitution as an expression, I
> just use /e. Can I do the same for a match?
You don't need to.
> For example:
>
> $string = "Mississippi";
> $expression = "Mis+is+p+i";
>
> if ($string =~ /$expression/) {
> # it should match
> }
Try this:
$expression = "Mis+is+ip+i";
Do I hear the sound of hand slapping forehead? :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 17:29:02 +0100
From: "Steven Primrose-Smith" <steven.peter.primrose-smith@avl.com>
Subject: Re: An /e for a match rather than a substitution
Message-Id: <7hulc1$3eu@fstgal00.tu-graz.ac.at>
Hi,
Thanks for your reply but maybe I didn't explain
clearly enough.
The value of $string and the value of $expression
are provided by the user at runtime. My example
obviously wasn't clear enough. How can I check
whether the expression provided by the user
matches the string provided by the user unless
the value of $expression is evaluated as an
expression and not as a string.
For example, if the user provides $string as "hello"
and $expression as "he\w\wo", the statement:
$string =~ /$expression/
needs to equate to true. If, in the above example,
$expression was "hi di ho", the statement should
give false. Without the /e modifier, "hello"
won't match "he\w\wo". Or is there another way
that I don't know.
Best wishes,
Steven
Tad McClellan wrote in message ...
>Steven Primrose-Smith (steven.peter.primrose-smith@avl.com) wrote:
>
>: If I want to evaluate the right side of a substitution as an expression,
I
>: just use /e. Can I do the same for a match?
>
>
> No.
>
> A m// doesn't even *have* a "right side".
>
> I dunno what you are meaning there...
>
>
>: $string = "Mississippi";
> ^
> ^ the $expression cannot match that letter...
>
>: $expression = "Mis+is+p+i";
>
>: if ($string =~ /$expression/) {
>: # it should match
>: }
>
>
> That is interpolation, not code eval()uation.
>
> That you _can_ do in a m// since it is "double quotish".
>
>
>--
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Wed, 19 May 1999 09:21:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: An /e for a match rather than a substitution
Message-Id: <MPG.11ac84fc64f9d127989aa8@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7hulc1$3eu@fstgal00.tu-graz.ac.at> on Wed, 19 May 1999
17:29:02 +0100, Steven Primrose-Smith <steven.peter.primrose-
smith@avl.com> says...
...
> For example, if the user provides $string as "hello"
> and $expression as "he\w\wo", the statement:
>
> $string =~ /$expression/
>
> needs to equate to true. If, in the above example,
> $expression was "hi di ho", the statement should
> give false. Without the /e modifier, "hello"
> won't match "he\w\wo". Or is there another way
> that I don't know.
As I responded to your stealth email, try:
$expression = 'he\w\wo';
or
$expression = "he\\w\\wo";
As Tad said, this is a "double quotish" context.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 16:57:03 GMT
From: Jared Hecker <jhecker@iago.nac.net>
Subject: Re: best way to database stuff using Perl?
Message-Id: <z3C03.106$kn3.5452@nntp1>
In comp.lang.perl Dr. A R Daniels <a.daniels@umist.ac.uk> wrote:
> I have found that Win32 - ODBC works well. Try the following web site for
> Note: This only applies to WinNT based servers - and lets face it lots of
> people (apart from the die hard 'shag microsoft' strange people) are moving
> over to this platform according to a survey by a leading IT company over
> here in the UK.
Actually, here in the "colonies", Linux servers grew as much
percentage-wise last year as NT for databases. I would put an
equally-configured box running Red Hat 5.2 against NT with both running,
say, Oracle or Sybase any day of the week.
Regards,
jh (also a Sybase DBA :-) )
--
Jared Hecker | HWA Inc. - Oracle architecture and Administration
jared@hwai.com | ** serving NYC and New Jersey **
------------------------------
Date: Wed, 19 May 1999 16:32:45 GMT
From: Tzadik Vanderhoof <tzadikv@my-dejanews.com>
Subject: C superior to Perl in DB2 programming?
Message-Id: <7hup3e$8vb$1@nnrp1.deja.com>
I'm quite surprised that I have gotten no response to this question
(especially with such a provocotive subject :), so I'm reposting it.
The customer allowed me to write this thing in Perl and is now
regretting it, because it seems like it cannot be installed on a machine
without the DB2 SDK, whereas had it been written in C, it would not have
this problem. If this conclusion is wrong, PLEASE LET ME KNOW! If my
conclusion is right, PLEASE LET ME KNOW! Thanks!
Here is the original post:
----------
----------
Is there any way I can distribute my Perl script that uses DBD::DB2 to
machines that do not have the DB2 SDK installed?
I know that the DB2 SDK is necessary to *build* DBD::DB2 but question
why it should be necessary for simply *running* a script that *uses*
DBD::DB2.
One irritating aspect of this problem is that apparently a C program
that uses DB2 does not suffer from this problem. You just "bind" the C
program with the DB2 database (on a machine that has the DB2 SDK) and
then you can distribute the compiled and "bound" C program to a machine
that does *not* have the SDK. Thus if this is true, programming DB2 apps
in C has a distinct advantage over programming them in Perl, which rubs
me the wrong way.
One problem with this issue is how to copy a DBD::DB2 module from one
machine to the other (without building it on the second machine). I
tried doing such a copy recently by simply using "tar" to package up the
relavant directorys in /usr/local/lib/perl5, but I could not run my
script on the second machine. I would get:
Can't load
/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2.so' for
module DBD::DB2: dlopen:
/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2 .so:
A file or directory in the path name does not exist. at
/usr/local/lib/perl 5/5.00502/aix/DynaLoader.pm line 168.
(The "DB2.so" file it claims does not exist actually does exist...the
problem seems to be something that is called from "DB2.so". The only
way I could come up with to solve this problem was to install the DB2
SDK on the second machine and rebuild DBD::DB2 there, which the customer
does not want as a production solution. They do not want the SDK
installed in production)
--
Thanks,
Tzadik
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 18:48:35 +0200
From: Eduardo Fernandez Corrales <eduardo@sistelnet.es>
Subject: Changing format of (long!) flat text file to make searches faster
Message-Id: <3742EB63.8BF1A7C8@sistelnet.es>
Hello,
I want to make a catalog of articles searchable in Internet, via some
CGI scripts in perl and
forms in web pages.
I have a comma separated file, running about 70000 lines long, and have
developed a simple cgi
that searchs the fields in the file and outputs the results to a web
page.
The problem though, is that this is too slow.
I need to convert the file to a format that makes searchs faster.
The search is made over two fields of the 8 that each register has.
-What kind of file format could I use?
Please point me in some direction.
Thanks in advance.
--
Eduardo Fernandez
------------------------------
Date: Wed, 19 May 1999 12:26:04 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: evalling __END__ and <DATA>
Message-Id: <7huopq$kqm$1@owl.slip.net>
<jed@glug.hip.berkeley.edu> wrote in message
news:m3aev2bab8.fsf@glug.hip.berkeley.edu...
>
> Hi, ho.
>
> I'm trying to slurp some perl code out of another file and run it. If
> I eval this code, it halts at an __END__ without reading any DATA. For
> example, if I run this script:
>
> open (FILE,"file");
>
> while (<FILE>) {
> $code .= $_; # this is simplified for the sake of example
> }
> eval $code;
This won't help your root problem much, but the eval can always be written:
eval <FILE> || die "Some error message: $@" ;
Which looks even better(!) for STDIN:
eval <> || die "" ;
I don't _think_ you'll get much joy out of what you're trying to do,
unfortunately. Perhaps you might try converting the code you're eval()ing
into a module, where it should work. Or maybe require() it?
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: 19 May 1999 15:51:00 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: FAQ 4.41: How do I compute the difference of two arrays? How do I compute the intersection of two arrays?
Message-Id: <7huml4$dgq$1@pegasus.csx.cam.ac.uk>
Larry Rosler <lr@hpl.hp.com> wrote:
>
> grep !exists $count1{$_} ^ !exists $count2{$_},
> keys %count1, keys %count2;
>
>The negations are to quiet the pedants who will argue that TRUE returned
>by exists() in numeric context isn't necessarily 1.
You can't quieten a pedant that easily!
Why engage in such antics? Use boolean operators on boolean values,
in this case the 'xor' operator:
grep (exists $count1{$_} xor exists $count2{$_}),
keys %count1, keys %count2;
Mike Guy
------------------------------
Date: Wed, 19 May 1999 09:46:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.68: How do I handle binary data correctly?
Message-Id: <MPG.11ac8abc1b6806cb989aa9@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <3742da5c@cs.colorado.edu> on 19 May 1999 09:35:56 -0700, Tom
Christiansen <perlfaq-suggestions@perl.com> says...
...
> How do I handle binary data correctly?
>
> Perl is binary clean, so this shouldn't be a problem. For example,
> this works fine (assuming the files are found):
>
> if (`cat /vmunix` =~ /gzip/) {
> print "Your kernel is GNU-zip enabled!\n";
> }
>
> On some legacy systems, however, you have to play tedious games
> with "text" versus "binary" files. See the section on "binmode" in
> the perlfunc manpage, or the upcoming the perlopentut manpage
> manpage.
<RANT>
I guess I'll keep harping on this until the Perl writers and teachers
change their attitudes and their approach to this question. The proper
-- dare I say 'mature' -- answer is:
Use the "binmode" function immediately after opening the file.
The ANSI/ISO C Standard says to use modes "rb" "wb" or "ab" when opening
a binary file, without ascribing pejorative characteristics such as
'legacy systems' (whatever that means) to those implementations that
require it. So this Perl FAQ never gets asked about C -- there is no
question; that is The Way To Do It.
But of course, that section of the C Standard was written by Bill
Plauger, who sold and supported an eclectic multitude of C Library
implementations, not just the One True System.
How about it, Perl writers and teachers? Will you help to adapt the
Perl culture to current realities, or continue to advocate this purist
fantasy?
</RANT>
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 12:18:54 -0400
From: "Stephen Warren" <swarren@www.wwwdotorg.org>
Subject: Re: fetching specific info from a text file
Message-Id: <7huocd$kos$1@owl.slip.net>
Ala Qumsieh <aqumsieh@matrox.com> wrote in message
news:x3yyaimv120.fsf@tigre.matrox.com...
>
> "Brian Altman" <ba@iamd.com> writes:
>
> > Right now I am wondering if it is possible to 'get' specific data from
an
> > existing file (any text based file), and write it to a new file.
>
> Just open() it and read what you want.
> Checkout the documentation for open() in perlfunc.
The usual algorithm would be something like:
open input file ;
open output file ;
while ( read a line from input )
{
write to output file if ( its a line we want ) ;
}
close output file
close input file
Of course, if determining which data you want isn't a simple line-by-line
decision, you may need to expand the inner loop to do
substitution/pattern-matching with s///, m// etc.
--
Stephen Warren, Snr Systems Engineer, Technology House, San Francisco
mailto:swarren@techhouse.com http://www.techhouse.com/
mailto:swarren@wwwdotorg.org http://www.wwwdotorg.org/
MIME, S/MIME and HTML mail are acceptable
------------------------------
Date: Wed, 19 May 1999 15:07:43 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: File locks don't.
Message-Id: <pudge-1905991107450001@192.168.0.77>
In article <7hui5q$v59$1@news.iastate.edu>, "Darin Dugan"
<s1dugan@nospam.exnet.iastate.edu> wrote:
# Below is the main code I'm using for file locks while reading / writing
# files. The files do NOT get locked. Any ideas what I could be overlooking?
flock() on most systems creates an advisory lock, not a mandatory lock.
Any process can choose to ignore the lock.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 19 May 1999 10:32:24 -0500
From: "Darin Dugan" <s1dugan@nospam.exnet.iastate.edu>
Subject: Re: File locks don't.
Message-Id: <7hulis$v50$1@news.iastate.edu>
How would you recommend that I create a mandatory lock or work around this?
Chris Nandor <pudge@pobox.com> wrote in message
news:pudge-1905991107450001@192.168.0.77...
> # Below is the main code I'm using for file locks while reading / writing
> # files. The files do NOT get locked. Any ideas what I could be
overlooking?
>
> flock() on most systems creates an advisory lock, not a mandatory lock.
> Any process can choose to ignore the lock.
------------------------------
Date: Wed, 19 May 1999 16:34:29 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: File locks don't.
Message-Id: <pudge-1905991234320001@192.168.0.77>
In article <7hulis$v50$1@news.iastate.edu>, "Darin Dugan"
<s1dugan@nospam.exnet.iastate.edu> wrote:
# How would you recommend that I create a mandatory lock or work around this?
Depends on the system. On most Unices, you could chmod it so it is read-only.
my $file = 'test1';
open F, "> $file" or die $!;
my $mode = (stat($file))[2];
chmod 0444, $file;
print F 'foo'; # you opened in write mode, so OK for you, no one else can
# write unless they already opened it for writing
close F;
chmod $mode, $file;
Problem here is that someone might have already opened it for writing.
Maybe you both opened it for writing at the same time, and so you are both
overwriting each other's data. Oops.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Wed, 19 May 1999 15:52:11 GMT
From: none@ever.net (soybean)
Subject: Re: fork() it OVER!!
Message-Id: <3742db82.180502058@news.supernews.com>
On Wed, 19 May 1999 07:24:38 -0500, "Wassim Metallaoui"
<wassimk@iname.com> wrote:
Simply put, this program splits into two programs one of wich keeps
talking to the webserver and the other does you mailing.
fork is the command to split a program into two programs, commonly
referd to as "parent" and "child".
After the program splits (forks), both programs (parend, child) need a
way to tell if they are the parent or child. This is because they
probably want to do two different things, hence the decision to do a
fork. So the way to detect if the process is a parent or child is to
check the return of fork, which is put in $pid in this example.
And after the split, both programs are still connected to the
webserver, so it is a good idea for one to close that connection --
hence close(STDOUT);
The truth of the matter is that if you don't understand this program
then you should not play with fork without showing you code to you
system admin, because you could hose your system if you make a mistake
At least, read some documentation.
>Can anyone tell me what the heck the fork and pid; stuff in here does.. This
>is how I was told to mass mail to everyone listed in a text file.. I was
>told to do it this way because it would keep the browser from timing out by
>starting a new process... Please explain it.. Can you please send the
>explanation to wassimk@iname.com or you can post a reply... Either way will
>work.. I appreciate all the help you can give me...
>
>
>
>$pid = fork(); #what in the world is this?
>print "Content-type: text/html \n\n fork failed: $!" unless defined
>#????????
>
>$pid; #????????
>if ($pid) { #???????????
> #parent, what in the world is a parent!
>print "Content-type: text/html \n\n";
>print <<EOF;
><HTML><HEAD><TITLE>Mailing Success</TITLE></HEAD><BODY
>BGCOLOR=\"#FFFFFF\Mail sent successfully!</BODY></HTML>
>EOF
>
> exit(0); #what does the 0 mean?
> }
>else {
> #child, what in the world is a child?
>
> close (STDOUT); #what does this do?
>
>open (LIST,"<$listdir/emails.txt");
> if ($LOCK_EX)
>
>
> flock(LIST, $LOCK_EX);
> }
> @emails = <LIST>;
> close (LIST);
>
>foreach $line (@emails) {
> chomp($line);
>
>open (MAIL, "|$mailprog -t") || print "Can't start mail program";
> print MAIL "To: $line\n";
> print MAIL "From: $youremail\n";
> print MAIL "Subject: $INPUT{'subject'}\n\n";
>
>
> print MAIL "$INPUT{'message'}";
> print MAIL"\n\n";
> close (MAIL);
>
>
> }
> }
> }
>
>
------------------------------
Date: Wed, 19 May 1999 12:36:44 -0400
From: Doug Seay <dms@rtp-bosch.com>
Subject: Re: fork() it OVER!!
Message-Id: <3742E89C.4023A771@rtp-bosch.com>
Wassim Metallaoui wrote:
>
> $pid = fork(); #what in the world is this?
perldoc -f fork
> print "Content-type: text/html \n\n fork failed: $!" unless defined
> #????????
perldoc perlvar
and then look for the $! if you don't understand that part.
The text is HTML type stuff. You should be able to recognize it by the
text/html bit. Although lots of HTML stuff ends up in this newsgroup,
that is more "problem domain" and not truely on-topic.
> $pid; #????????
That $pid was acually the argument for defined. Your mailer
word-wrapped it.
> if ($pid) { #???????????
> #parent, what in the world is a parent!
What? You have no idea what a parent is? I'm sorry, but this isn't the
right forum for basic computer science concepts[*]. Get any book on
computers and start reading. The pid concept is related to that whole
parent/child/fork thingie. This vocabulary is Unix based, but I think
you'll find the words in most Windows/XX books.
> print "Content-type: text/html \n\n";
> print <<EOF;
> <HTML><HEAD><TITLE>Mailing Success</TITLE></HEAD><BODY
> BGCOLOR=\"#FFFFFF\Mail sent successfully!</BODY></HTML>
> EOF
>
> exit(0); #what does the 0 mean?
You ought to be able to find that concept in the same book where you
found out about parents/children/fork. For a quick tutorial, try
perldoc -f exit
> }
> else {
> #child, what in the world is a child?
This concept is related to parent.
> close (STDOUT); #what does this do?
perldoc -f close
The rest is snipped.
I don't mean to be overly rude, but you seem to have copied someone's
code and have *no* idea what is going on. This forum is for people to
ask questions about Perl, not to ask "would someone please read this,
tell me what it does, and save me from actually understand what is going
on".
Start by "perldoc perl" and do some reading. Lots of reading. Maybe
Randal's book (perldoc perlbook) would help. I've never read it, but
I've heard nothing but good things about it. I personally like the
Camels , but if you can't handle parent/child, I don't think you're up
for that quite yet. Crawling before walking and all of that.
Best of luck learning enough about programming in general and Perl in
particular to understand your script.
- doug
[*] I say "basic" because we discussed it in my freshman year as an
undergrad. although I don't think that I did any programming using
parent/child stuff until my sophmore year. I define any concept covered
in the first two years of a Computer Science degree to be "basic". Of
course, YMMV.
------------------------------
Date: Wed, 19 May 1999 12:07:25 -0400
From: "Winfield Henry" <winfieldh@mindspring.com>
Subject: Help with 'unlink'ing files
Message-Id: <7huni6$4mc$1@nntp1.atl.mindspring.net>
Hi there,
I have a little script that calls the 'unlink' function to delete a certain
file. I have it working nicely on my local machine (W98, Personal web
server). When I put it on a Unix server, give it all applicable permissions,
it will not delete the specified file. Here is the snippett that does the
deleting.
if (($action =~ /delete/i)&&($delfile ne "")){
unlink ($delfile);
print<<html;
<h>"$delfile" has been deleted</h>
Any suggestions would be greatly appreciated, Thank you. Winfield
------------------------------
Date: Wed, 19 May 1999 16:29:39 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Help with 'unlink'ing files
Message-Id: <3742e696.15904449@news.insnet.net>
On Wed, 19 May 1999 12:07:25 -0400, "Winfield Henry"
<winfieldh@mindspring.com> enlightened us thusly:
>I have a little script that calls the 'unlink' function to delete a certain
>file. I have it working nicely on my local machine (W98, Personal web
>server). When I put it on a Unix server, give it all applicable permissions,
>it will not delete the specified file.
Check that the current working directory is what you expect it to be.
The cwd for CGIs varies from one server to another, particularly when
an MS server is involved.
[Copying newsgroup posts to me by mail is considered rude]
--
David Cantrell, part-time Unix/perl/SQL/java techie
full-time chef/musician/homebrewer
http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: 19 May 1999 16:31:49 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Help with 'unlink'ing files
Message-Id: <7hup1l$o7o$1@info2.uah.edu>
In article <7huni6$4mc$1@nntp1.atl.mindspring.net>,
"Winfield Henry" <winfieldh@mindspring.com> writes:
: I have a little script that calls the 'unlink' function to delete a certain
: file. I have it working nicely on my local machine (W98, Personal web
: server). When I put it on a Unix server, give it all applicable permissions,
: it will not delete the specified file. Here is the snippett that does the
: deleting.
:
: if (($action =~ /delete/i)&&($delfile ne "")){
: unlink ($delfile);
: print<<html;
: <h>"$delfile" has been deleted</h>
ALWAYS CHECK THE RETURN VALUE WHEN YOU MAKE A SYSTEM CALL!!
Perhaps you should use something like
if ($action =~ /delete/i and $delfile) {
if (unlink $delfile) {
print "`$delfile' has been deleted";
}
else {
print "Error: failed unlink $delfile: $!";
}
}
Greg
--
Be warned that being an expert is more than understanding how a system is
supposed to work. Expertise is gained by investigating why a system doesn't
work.
-- Brian Redman
------------------------------
Date: Wed, 19 May 1999 15:49:35 GMT
From: rslifka@my-dejanews.com
Subject: HELP: Internet Module
Message-Id: <7humie$703$1@nnrp1.deja.com>
Do the perl internet libraries cache? I believe
this would be the only explanation for what's
happening. If so, is there any way for me to
have HTTP->Request() get a new page every time?
When making my HTTP reqs via perl, it returns the
old page, hourrrs after it's been changed.
Plz email any replies: rslifka@calvex.com
thanks!
- Rob
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 15:58:21 GMT
From: rslifka@my-dejanews.com
Subject: HELP: Perl Internet (HTTP->Request())
Message-Id: <7hun2q$7ek$1@nnrp1.deja.com>
Is there ANY way to have it not cache requests? I get the saaame page
hours after it's been changed!
plz email rslifka@calvex.com, thanks!
- r
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 15:47:09 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Help: Win32::Registry
Message-Id: <7humd7$bq5$1@news.mch.sbs.de>
In article <3742CDC4.64144642@yahoo.com>, a_sovakar@yahoo.com wrote:
[snip]
>Hi Michel,
>
>The next lines show my little test program.
>
>use Win32::Registry;
>
>$key = "SOFTWARE\\TEST";
>$name = "TestValue";
>
>$main::HKEY_LOCAL_MACHINE->Open($key, $CurrVer) || die "Open: $!";
>
>$CurrVer->QueryValue($name, $value);
>
>print "value: $value\n";
[snap]
I'm sorry, I tested the default value of a key, but not the value for
a specific name. This seems to cause problems indeed, and gives
the following error message :
QueryValue : No such process at testreg line 8.
However, if you use the following, it works :
$CurrVer->QueryValueEx($name, $type, $value) || warn "QueryValueEx : $!";
Have you also looked at Win32::TieRegistry ?
Michel.
------------------------------
Date: 19 May 1999 15:55:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I skip the "." and ".." files when reading in a directory
Message-Id: <3742d0ff@newsread3.dircon.co.uk>
Barcode <barcode@ice.net> wrote:
> I have a script which reads a named directory, opens each file and removes
> the specified line. However, when I encounter the working and parent
> directory files (. and ..) the rename function fails.
>
You can replace the sort readdir(DIR) whatever with
foreach(sort grep !/^\.{1,2}$/,readdir(DIR) )
{
#
}
chechout the perlfunc entry on grep and the perlre manpage if you are not
sure what is going on there.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: Wed, 19 May 1999 15:20:05 GMT
From: mjzanghi@my-dejanews.com
Subject: Re: How to access a https site
Message-Id: <7hukr2$5hp$1@nnrp1.deja.com>
Hi, I have the same problem as you have! Has anyone responded yet? I
haven't seen any postings to deja news regarding your question. I was
wondering if anyone has emailed you with a response and if so, could
you please pass the info on to me. I would really appreciate it.
Thanks,
Mike
In article <7hs55u$f76$1@nnrp1.deja.com>,
yong321@yahoo.com wrote:
> I want to write a simple Perl script to access a Web page using Secure
> Socket Layer. But lwp-request doesn't support https. All I want is to
> go to https://ourserver/ and send a username/password to see if our
> database is down again. I want to run it every midnight for this check
> until I find the real problem with our database.
>
> Can anyone tell me how to access a SSL web page? Thanks.
>
> Yong
> Email:yong321@yahoo.com
>
> --== Sent via Deja.com http://www.deja.com/ ==--
> ---Share what you know. Learn what you don't.---
>
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5724
**************************************