[12126] in Perl-Users-Digest
Perl-Users Digest, Issue: 5726 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 19 15:07:13 1999
Date: Wed, 19 May 99 12:00:24 -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: 5726
Today's topics:
Re: about: use strict; <cassell@mail.cor.epa.gov>
Accessing Remote Database <venugopalvv@hotmail.com>
Re: An /e for a match rather than a substitution (Tad McClellan)
Re: An /e for a match rather than a substitution (Larry Rosler)
Re: best way to database stuff using Perl? <perlguy@technologist.com>
boolean test input... <jjm69@columbia.edu>
Re: can someone help me with locking??? <cassell@mail.cor.epa.gov>
CGI/ISAPI problem <gschmidl@xxx.gmx.at>
Re: eliminating lines in extracted text <cassell@mail.cor.epa.gov>
Re: FAQ 4.15: How do I find yesterday's date? <bill@fccj.org>
Re: FAQ 4.41: How do I compute the difference of two ar (Larry Rosler)
Re: FAQ 4.65: Why does passing a subroutine an undefine <bill@fccj.org>
Re: FAQ 4.68: How do I handle binary data correctly? (Andrew Allen)
Re: FAQ 4.68: How do I handle binary data correctly? (Larry Rosler)
Re: fork() it OVER!! <cassell@mail.cor.epa.gov>
Re: How can I skip the "." and ".." files when reading <stampes@xilinx.com>
How terminated a Perl Loop with a signal? <gebhardt@erinet.com>
Re: How to access a https site <cassell@mail.cor.epa.gov>
How to reduce the memory footprint? <carriec@doc.state.vt.us>
Re: Looking for Phonetic Program in Perl <bogart@exis.net>
Re: Looking for Phonetic Program in Perl (Spica)
Open/close ?problem?, please help, <kirasa@oz.net>
Printing hash of hashes. rajeshsharda@my-dejanews.com
radio buttons... <anagaraj@ford.com>
Regex match hash key? alex@santa.asf.alaska.edu
Re: Regex match hash key? (PhelanP)
We are Looking for Perl Programmer with experience with <kc@dakotaairparts.com>
Re: XML::XQL <nlymbo@mindspring.com>
Re: Y2K. localtime(time) <bill@fccj.org>
Re: Y2K. localtime(time) <bill@fccj.org>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 19 May 1999 10:06:29 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: about: use strict;
Message-Id: <3742EF95.FD0527E3@mail.cor.epa.gov>
Bart Lateur wrote:
>
> Austin Ming wrote:
>
> >Why it is a good recomendation to use "use strict;" after "#!/usr/bin/perl" ?
>
> Because it doesn't work if you swap those lines...
>
> I'm not a big fan of "use strict" myself, except for
> "use strict qw(refs);". I always use "-w".
>
> But the answer that you're looking for is that there is an extra check
> for mistypes of variables' names. You KNOW which global variable there
> are, because you have to declare them. That's nice, especially for
> rather large scripts.
And also for rather small scripts, if yuo type like me.
^^
[example appearing conveniently here || ]
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 19 May 1999 14:54:00 -0500
From: "Venu Gopal" <venugopalvv@hotmail.com>
Subject: Accessing Remote Database
Message-Id: <374308c8@discussions>
Hi,
I need to access a database thru network
using a perl program. Can i do that? In other
words just like RMI objects. If any one helps
then it will be greatful.
Thanks in advance.
Venu
--Posted from EarthWeb Discussions. http://discussions.earthweb.com
------------------------------
Date: Wed, 19 May 1999 08:10:39 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: An /e for a match rather than a substitution
Message-Id: <vn9uh7.k1c.ln@magna.metronet.com>
[ Please put your comments following the quoted text that you
are commenting on. Usenet is not Jeopardy where things are
done in reverse chronological order.
Don't quote .sigs
]
: 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...
Did you go fix the expression and try it?
I think not!
How come?
: >: $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".
Steven Primrose-Smith (steven.peter.primrose-smith@avl.com) wrote:
: Thanks for your reply but maybe I didn't explain
: clearly enough.
Yes you did.
: The value of $string and the value of $expression
: are provided by the user at runtime. My example
: obviously wasn't clear enough.
Yes it was.
: 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.
The way I said it could, which was the way you had it then
(except you had an error in your $expression), and the way
you have it below!
: For example, if the user provides $string as "hello"
: and $expression as "he\w\wo", the statement:
: $string =~ /$expression/
: needs to equate to true.
It will.
: If, in the above example,
: $expression was "hi di ho", the statement should
: give false.
It will.
: Without the /e modifier, "hello"
: won't match "he\w\wo".
Yes it will.
: Or is there another way
: that I don't know.
You don't need another way.
-----------------------
#!/usr/bin/perl -w
use strict;
my $string = 'hello';
my $expression = 'he\w\wo';
if ( $string =~ /$expression/ )
{ print "matched\n" }
else
{ print "NOT matched\n" }
$expression = 'hi di ho';
if ( $string =~ /$expression/ )
{ print "matched\n" }
else
{ print "NOT matched\n" }
-----------------------
output:
matched
NOT matched
Works for me.
It would work for you if you could be troubled to try it...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 19 May 1999 11:21:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: An /e for a match rather than a substitution
Message-Id: <MPG.11aca0fdbfb7385d989aac@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <vn9uh7.k1c.ln@magna.metronet.com> on Wed, 19 May 1999
08:10:39 -0400, Tad McClellan <tadmc@metronet.com> says...
...
> Don't quote .sigs
...
> Steven Primrose-Smith (steven.peter.primrose-smith@avl.com) wrote:
...
> : For example, if the user provides $string as "hello"
> : and $expression as "he\w\wo", the statement:
>
> : $string =~ /$expression/
>
> : needs to equate to true.
>
> It will.
It won't.
...
> : Without the /e modifier, "hello"
> : won't match "he\w\wo".
>
> Yes it will.
No, it won't.
...
> my $expression = 'he\w\wo';
You changed his comparison string to make it work. :-)
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
We've been here before. If you don't want your .sig quoted, try again
to get the space at the end of the sig-dash. It isn't there now, as you
can see.
--
(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:28:45 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: best way to database stuff using Perl?
Message-Id: <3742F4CD.FB4293C9@technologist.com>
I suppose that the "survey" was funded and initiated by a reputable
company such as Microsoft too! :-)
I have found that along with the "major" names for Unix databases, MySQL
works incredibly well too!
I have a simple Perl SQL tutorail at http://www.inlink.com/~perlguy/sql
if you would care to see it working.
If you want to see another example of a MySQL database in action, try
http://www.mastercard.com/atm
BTW, the actual test database is run from my home machine via a dialup
connection because I didn't want to pay my ISP extra for a database. I
was being cheap ;^)
Brent
Jared Hecker wrote:
>
> 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 13:55:56 -0400
From: Jeremiah J Marble <jjm69@columbia.edu>
Subject: boolean test input...
Message-Id: <Pine.GSO.4.10.9905191346440.6501-100000@bonjour.cc.columbia.edu>
hi *,
i was wondering if anyone had written, or could refer me to, a good
function to parse a line like
-->
html AND javascript AND (perl NOT (vb OR java))
<--
in order to extract, using those keywords, the info from a structure like
-->
$prog_lang{$keyword};
<--
any suggestions, especially on how to handle the parentheses?
thank you,
jeremiah
_______________
jeremiah marble
------------------------------
Date: Wed, 19 May 1999 11:29:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: can someone help me with locking???
Message-Id: <3743030A.D710340@mail.cor.epa.gov>
Cameron Dorey wrote:
>
> [cc'd to md]
>
> Marc Dietrich wrote:
> >
> > try the flock mechanism. See perldoc -f flock or man flock. This only
> > works on Unix Systems.
>
> BRAAAK! Wrong! Next contestant spin the Wheel, please. flock works on
> WinNT, but not on Win9x. I believe I have also seen that it works on
> VMS, but have had no experience with that OS since 1982.
There may still be some problems with the VMS implementation.
Ask Dan Sugalski.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 19:48:14 +0200
From: "Gunther Schmidl" <gschmidl@xxx.gmx.at>
Subject: CGI/ISAPI problem
Message-Id: <3742fa52.0@alijku02.edvz.uni-linz.ac.at>
I'm having huge troubles with below script (apart from the obvious bad
style, probably, but I'm a beginner, so please bear with me :-). In
interactive mode (that is, on the command line), everything works perfectly
well - but if I want to run the script on a Microsoft IIS via Perl-ISAPI,
'File::Find' stops processing every file recursively and only 'does' the
directories; this without my changing a single line. The script is running
as IIS-Administrator, so I'm guessing it's not a security problem. Is there
a bug in File::Find, am I doing something fundamentally wrong, or what is
the matter?
===BEGIN INCLUDED FILE VOLLTEXT.PLX===
Content-type: text/plain
#! perl -w
$| = 1;
use CGI qw(:standard);
# use CGI::Carp;
use File::Find;
my $dir = "archiv/";
my $sdir = "c:/projekte/20jahre/archiv/";
my $search = param("such") || "";
print "<HTML><HEAD><TITLE>Results:</TITLE></HEAD><BODY>";
if ($search eq "")
{
print "<H1>Error: no parameter passed!</H1></BODY></HTML>";
exit;
}
sub search_text
{
my $line;
# ignore non-.html files and directories
print $File::Find::name; # this is where it seems to break
return if ($File::Find::name !~ m/\.html/i);
return if (-d $File::Find::name);
# open file
open(FILE, $File::Find::name) || die "couldn't open file: $!";
# search
DOIT: while(defined($line = <FILE>))
{
if ($line =~ m/$search/ig)
{
close(FILE);
open(FILE, $File::Find::name);
print "<A HREF=\"$File::Find::name\">$File::Find::name</A>";
print "<PRE>";
for (my $i = 1; $i < 4; $i++)
{
$line = <FILE>;
$line =~ s/</</;
$line =~ s/>/>/;
print "$line<BR>";
}
print "</PRE><HR>";
last DOIT;
}
}
close(FILE);
}
find(\&search_text, $sdir);
print "</BODY></HTML>";
===END INCLUDED FILE VOLLTEXT.PLX===
--
+------------------------+----------------------------------------------+
+ Gunther Schmidl + "I couldn't help it. I can resist everything +
+ Ferd.-Markl-Str. 39/16 + except temptation" -- Oscar Wilde +
+ A-4040 LINZ +---------------+------------------------------+
+ Tel: 0732 25 28 57 + ICQ: 22447430 + IF: http://sgu.home.dhs.org/ +
+------------------------+---+-----------+------------------------------+
+ gschmidl (at) gmx (dot) at + please remove the "xxx." before replying +
+----------------------------+------------------------------------------+
------------------------------
Date: Wed, 19 May 1999 11:21:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: eliminating lines in extracted text
Message-Id: <3743012B.E5B22F61@mail.cor.epa.gov>
rbbdsb wrote:
>
> Using the range operator, it is easy to extract lines that occur between two
> patterns, for example
>
> if (/foo/ .. /bar/) { print; }
Right. You can write this in current Perls as:
print if (/foo/ .. /bar/);
And you can get everything except those pieces like this:
print unless (/foo/ .. /bar/);
> It is also possible to exclude specific absolute lines by doing something
> like:
>
> next line if (1 .. /^$/); # skip header lines
or:
print unless (1 .. /^$/);
> What I need to do is eliminate a couple of header and trailer lines at from
> the extracted lines, but the absolute line numbers aren't known in advance.
> What is the most efficient way to do this? Is pattern matching the only
> option?
That depends on how one knows where the header ends and the text
begins (and similarly for the trailer). If there is no way of
describing the break, then there is no way of setting it up in
code. Do any of my suggestions above help? If not, then
perhaps you could post more info on your problem, along with
a short program you've written that makes a first stab at it.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 12:29:48 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: FAQ 4.15: How do I find yesterday's date?
Message-Id: <3742e6c0.0@usenet.fccj.cc.fl.us>
In article <7hrm6l$2sn$1@news.auaracom.net>, "Jim The Perl Guy"
<news@thebeaches.to> wrote:
> WHAT??????
>
> No matter what day of the week, month, year, decade or century, there are
> only 86,400 seconds unless it's a daylight savings switch. In that case,
> you'll have to write a rather large sub to recognize those dates. Doable but
> it only makes a difference twice a year. Is it that much of a difference?
I think you, may have missed a part of the thread;
this was completely answered (again) with code attached.
The code fragment was really short and to the point.
HTH,
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: Wed, 19 May 1999 10:15:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
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: <MPG.11ac918221e9b1e4989aaa@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7huml4$dgq$1@pegasus.csx.cam.ac.uk> on 19 May 1999 15:51:00
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk> says...
> 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;
Very cool. I have been hung up on the precedence-differentiating
properties of the semantically identical short-circuiting operators:
Semantics: bitwise logical logical
Precedence: high high low
Short-circuit: no yes yes
& && and
| || or
But as there is no equivalent short-circuiting exclusive-or operator:
^ ^^ xor
NO!
I didn't think to use logical exclusive-or (spelled 'xor') as the
alternative to bitwise exclusive-or (spelled '^') to achieve the desired
semantics.
Thanks for the eye-opener. This is a 'slicker' implementation of
symmetric set difference than mine, which is 'slicker' than the original
proposal.
--
(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:25:47 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: FAQ 4.65: Why does passing a subroutine an undefined element in a hash create it?
Message-Id: <3742e5ce.0@usenet.fccj.cc.fl.us>
In article <MPG.11ac599db6d60f39989a9e@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:
>
> In article <374270d2@cs.colorado.edu> on 19 May 1999 02:05:38 -0700, Tom
> Christiansen <perlfaq-suggestions@perl.com> says...
> ...
>> Why does passing a subroutine an undefined element in a hash create it?
<snip>
>> This has been fixed as of perl5.004.
>
<snip>
>
> Perhaps the best thing to do with this 'F'AQ is to drop it completely.
> As the Question has no relationship to current reality, it can no longer
> be Frequently Asked, can it?
>
Do we ask it, then we should be told to upgrade our Perl?
Or, does the FAQ stay and the note to reader say Upgrade?
Just a side rambling...
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: 19 May 1999 17:08:13 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: FAQ 4.68: How do I handle binary data correctly?
Message-Id: <7hur5t$o12$1@fcnews.fc.hp.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: [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.
So maybe we should make this the Perl Way To Do It:
open("*>binaryfile");
open("*<binaryfile");
(the character "*" meaning binary, open to suggestions). 'binmode'
always seemed like a hack. Course, we should still keep it around
for those 'legacy' apps ;)
Andrew
------------------------------
Date: Wed, 19 May 1999 11:06:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FAQ 4.68: How do I handle binary data correctly?
Message-Id: <MPG.11ac9d6636cc2eb0989aab@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7hur5t$o12$1@fcnews.fc.hp.com> on 19 May 1999 17:08:13 GMT,
Andrew Allen <ada@fc.hp.com> says...
> Larry Rosler (lr@hpl.hp.com) wrote:
...
> : 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.
>
> So maybe we should make this the Perl Way To Do It:
>
> open("*>binaryfile");
> open("*<binaryfile");
>
> (the character "*" meaning binary, open to suggestions). 'binmode'
> always seemed like a hack. Course, we should still keep it around
> for those 'legacy' apps ;)
I'm concerned more about treating all Perl implementations as first-
class citizens than about the syntax. As your approach doesn't add
semantics that I can perceive, I'd be very happy to stick with the
existing 'binmode' hack (as you put it).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 19 May 1999 11:10:38 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: wassimk@iname.com
Subject: Re: fork() it OVER!!
Message-Id: <3742FE9E.B9AD8C73@mail.cor.epa.gov>
[courtesy cc sent to poster]
Wassim Metallaoui wrote:
>
> 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...
Okay, I'm posting and e-mailing. You're going to have to read up
on this some. There's more to fork() than is appropriate here.
I suggest that you read the manpage next:
man fork
and then the section on the Perl fork() function in the perlfunc
manpage:
perldoc perlfunc
The basic idea is simple. If you try to do a long process from
your webserver, eventually the browser will time out. HTTP is like
that. But.. what if you create another process and have it do
the dirty work somewhere else, while you go on about your work
and keep that browser happy? So you create a new process to
do the mailing part.
Your OS's fork() causes the creation of that process. It makes
a new process (the child process) which is an exact copy of the
calling process (the parent process). The child process
inherits its attributes from the parent process. Hence the
names 'child' and 'parent'.
> $pid = fork(); #what in the world is this?
The process ID (PID). The Perl fork() function works like
the unix OS fork(). Perl is in general very unixish.
Which in most cases is A Good Thing.
If Perl's fork() succeeds, it returns the child's pid to
the parent process (which will have another pid - the same
one it had before you forked). The function also
returns 0 [zero] to the child, so that the processes can
tell who's the child and who's the parent.
If Perl's fork() fails, then $pid above will have the value
undef [undefined] in the parent process. Obviously,
since the fork() failed, there is no child process. So:
> print "Content-type: text/html \n\n fork failed: $!" unless defined
> #????????
>
> $pid; #????????
Please don't insert comments in the middle of the code like
that when you're writing real code. But now you see what's going
on. Unless $pid is defined, the fork() failed. So you
print the failure message.
Now then, $pid greater than 0 indicates that you're in the
parent process, and so you should print the HTML:
> 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?
It just means that you're exiting and announcing
that you exited with a 0 status. It's an error
code.
Now here, in the case where $pid==0, you're
the child process:
> }
> else {
> #child, what in the world is a child?
>
> close (STDOUT); #what does this do?
The child inherits the open file descriptors from
the parent. stdout, stdin, stderr, whatever.
If you don't close stdout in the child process
and let only the parent process print() to it,
the browser will think that you want to keep
talking to it, and you'll have problems.
> 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);
>
> }
The indenting in this code is verblunget. But you
probably want to end the 'child' section of the code
with an exit() so that the child process doesn't accidentally
exit this conditional and go wandering through the code
that's only for the parent process:
exit 0;
> }
> }
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 19 May 1999 17:42:51 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: How can I skip the "." and ".." files when reading in a directory
Message-Id: <7hut6r$a23@courier.xilinx.com>
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.
: How can I skip the opening of the two files and continue with the rest?
simple...exclude them! ;)
: foreach (sort readdir(SCREEN)) {
foreach (sort grep !/^\.\.?/,readdir(SCREEN)) {
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Wed, 19 May 1999 18:29:53 GMT
From: JG <gebhardt@erinet.com>
Subject: How terminated a Perl Loop with a signal?
Message-Id: <37430247.C5215D34@erinet.com>
I have a shell script that calls a perl script. The perl script displays
a menu and it contains an 'until' loop to redisplay the menu if the
selection is not valid and it exits the loop when the user enters 0..
When the rug is pulled out from the perl program (IE.. telnet session
terminated) the shell script ends but the perl loops in the 'until' 0
section. Is there a signal I can trap that the mom process (shell
script) sends to the child when it dies?
------------------------------
Date: Wed, 19 May 1999 11:15:16 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to access a https site
Message-Id: <3742FFB4.2433CD5E@mail.cor.epa.gov>
yong huang wrote:
>
> After I posted the question, I found www.openssl.org. And also found
> Net::SSLeasy module on CPAN. But since I use ActiveState Perl for WindowsNT,
> I haven't figured out how to install a module not shown by the "ppm search"
> command. (ppm is ActiveState's perl package manager). I'll do a little
> research. What's your $^O?
You'll want to read the HTML docs that ActiveState Perl installed
on your system. Go to the "ActivePerl FAQ" section and look
under the heading "Modules and Samples". The very first question
in there is: "How can I use modules from CPAN?"
Use the docs, Luke...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 19 May 1999 12:19:37 -0400
From: Carrie Coy <carriec@doc.state.vt.us>
Subject: How to reduce the memory footprint?
Message-Id: <3742E499.EBDED7B2@doc.state.vt.us>
I've written a perl script to provide a simple front-end menu to about
400 terminal users.
It uses Curses 1.02. The menu consumes about 2.5MB per user, which
really adds up.
I'm using the perl that came pre-installed on our Linux box:
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=linux, osvers=2.0.34, archname=i386-linux
uname='linux porky.redhat.com 2.0.34 #1 thu may 7 10:17:44 edt 1998
i686 unknown
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O2', gccversion=2.7.2.3
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
stdchar='char', d_stdstdio=define, usevfork=false
intsize=4, longsize=4, ptrsize=undef, doublesize=undef
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=, so=so
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Could I benefit from a libperl.so? Or what else might I do to shrink
this beast?
--
Carrie Coy
------------------------------
Date: Wed, 19 May 1999 13:02:59 -0500
From: Ed Bogart <bogart@exis.net>
Subject: Re: Looking for Phonetic Program in Perl
Message-Id: <3742FCD1.C03BC53@exis.net>
Effie Rover wrote:
>
> I'm looking for a Perl program that will take English (American) and
> break the words down into syllables, then convert the syllables to a
> phonic equivalent. Eventually, what I want this program to do is
> create rebuses (the picture puzzles you played when you were a kid
> where a picture of a steak followed by "-s" equals the word 'take').
> To make it flexible, I'd rather base the pictures on phonetic lookups
> rather than have a large word database.
>
It's been 20 years since I did any computational psycholinguistics (anyone
remember SNOBOL?) but unless things have changed a _lot_, it can't be done. The
problem is that the phonetic value of a string is an emergent property, not
closely encode. It's easy for us using our massively parallel brains but verrrry
hard for computers. Adding pictures to the mess is sure to make add another
magnitude to the difficulty.
> I'll program the bugger myself if I need to, but not being a great
> linguistic expert, I was hoping that a basic set of tools would
> already exist.
>
You might be able to over power it but it would require a complete dictionary of
all the words and syllables with all their phonetic equivalents built in. Some
large, well funded groups have tried problems like this and not got very far.
Good luck! 8^)
------------------------------
Date: Wed, 19 May 1999 18:06:48 GMT
From: reply@newsgroup.please (Spica)
Subject: Re: Looking for Phonetic Program in Perl
Message-Id: <3742fd31.501608114@news2.realtime.net>
On Wed, 19 May 1999 13:02:59 -0500, Ed Bogart <bogart@exis.net> wrote:
>
>
>Effie Rover wrote:
>>
>> I'm looking for a Perl program that will take English (American) and
>> break the words down into syllables, then convert the syllables to a
>> phonic equivalent. Eventually, what I want this program to do is
>> create rebuses (the picture puzzles you played when you were a kid
>> where a picture of a steak followed by "-s" equals the word 'take').
>> To make it flexible, I'd rather base the pictures on phonetic lookups
>> rather than have a large word database.
>>
>It's been 20 years since I did any computational psycholinguistics (anyone
>remember SNOBOL?) but unless things have changed a _lot_, it can't be done. The
>problem is that the phonetic value of a string is an emergent property, not
>closely encode. It's easy for us using our massively parallel brains but verrrry
>hard for computers. Adding pictures to the mess is sure to make add another
>magnitude to the difficulty.
>
>> I'll program the bugger myself if I need to, but not being a great
>> linguistic expert, I was hoping that a basic set of tools would
>> already exist.
>>
>You might be able to over power it but it would require a complete dictionary of
>all the words and syllables with all their phonetic equivalents built in. Some
>large, well funded groups have tried problems like this and not got very far.
>Good luck! 8^)
I'm quite the perl newbie and I don't know anything about programming
for this type of problem, but I seem to recall finding C/C++ Soundex
algorithms on the web at one time (when I was looking for something
else, actually). Is there such a thing already written for perl?
Spica
------------------------------
Date: Wed, 19 May 1999 11:54:14 -0700
From: "Kira S. Anastasia" <kirasa@oz.net>
Subject: Open/close ?problem?, please help,
Message-Id: <374308D6.F2FE8863@oz.net>
Hi All and TIA,
Not a perl guru :-) Yet :-).
I've written a CGI program using perl and I am getting some
rather odd behavior, which I think is related to the ?close?
function.
Running perl as installed from the RedHat 5.2 CDROM:
This is perl, version 5.004_04 built for i386-linux
(with 1 registered patch, see perl -V for more detail)
I've installed the necessary stuff to get the CGI to work...
I've read through the books I have until I am bleary eyed
:-). No luck searching anything I can find off the web
about this. I've either missed something or gotten dense
:-).
First I open the dataset for append of the data returned
from the form (this works):
[ ...]
$dbfile = "vdb";
# Open dataset append...
open ( VGB, ">>$dbfile" ) || print("Can't write to
$dbfile: error $!\n");
[ ... ]
once the info is written, I close it.
I open the file for the generated web page and put out the
headers:
[ ... ]
$abf = "xabk.html";
open ( HAGB, ">$abf" ) # || print("Can't write to $abf:
error $!\n");
or die "Can't open ($abf)output page file: $!";
[ ... ]
When I am ready for the information from the dataset I
re-open that for input (this works):
[ ... ]
open (VDB, "</home/users/vikki/public_html/vcgibin/vdb")
or die "Can't open dataset for input: $!";
[ ... ]
After I am done with it, I close it:
[ ... ]
close VDB or warn "Can't close input dataset: $!"; # Done
with the dataset now.
[ ... ]
Now I loose the output (HAGB). There are no messages other
than warnings about uninitialized variables in the server
error_log. The output from any print commands to HAGB seem
to go into the bit bucket.
I "solved" the problem by simply not closing the dataset
until I am done with the page output, but it is my habit to
close a file I am no longer using. Thus I *think* something
is wrong here.
Any thoughts or pointers on this matter greatly appreciated!
Thanks & take care, Vikki.
--
Respectfully, Kira Anastasia, kirasa@oz.net
"Walking on water and developing software to specification
are
easy as long as both are frozen" - Edward V. Berard.
Do not unto others, that which you would not have others do
unto you.
------------------------------
Date: Wed, 19 May 1999 17:02:26 GMT
From: rajeshsharda@my-dejanews.com
Subject: Printing hash of hashes.
Message-Id: <7huqr0$ab4$1@nnrp1.deja.com>
Hi,
I have a hash array.
The values in this hash array are the names of the other hash arrays.
Is there any way I can print the key-value pair of the hash arrays
which are in the values of the first hash array?
for example:
first hash is: $first_hash
its contents are:
Key Value
a A
b B
c C
d D
Here, the values A,B,C,D are hash arrays in themselves. how does one
can print the key/value of the hash array A(or B or C or D or all of
them)? We don't know the keys/values which will exist in the hash array
A/B/C/D.
Hope to get some help on this.
thanx.
rajesh
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 12:42:47 -0400
From: Ashwini Nagaraj <anagaraj@ford.com>
Subject: radio buttons...
Message-Id: <3742EA07.410ECE96@ford.com>
Hi All,
Can any one tell if it is possible to print radio buttons while fetching
rows in a DBI query. I am doing a customer satisfaction survey and all
the questions are printed out from the query through DBI. So, after
fetching each question I need to put radio buttons for rating that
particular question. I am using Perl-CGI. Any kind of help is greatly
appreciated.
Ash
------------------------------
Date: Wed, 19 May 1999 17:27:11 GMT
From: alex@santa.asf.alaska.edu
Subject: Regex match hash key?
Message-Id: <7hus9a$bk8$1@nnrp1.deja.com>
Hi, this is from Alex...
Is there a perl builtin, or efficient module function, which will let me
find out if any keys in a hash match a regular expression? Here is an
example of what I want to do:
My hash variable %friends includes:
Key Value
----- -----
Smith John
Doe Jane
Done All
I'd call a function, e.g. "rkey" like this:
if rkey(%friends, "/^D.*/")
to return true if any keys in %friends start with a "D" .
I'd do something like this:
@dees=rkey(%friends, "/^D.*/")
to make an array from all the values whose keys start with a "D" .
I know I can do this by using keys(%friends) and looping through the
results, but I thought if there was a builtin or an efficient module
function it would be faster than my interpreted loop.
Thank you for your time,
-Alex (:-)
rbaxte03@harris.com
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 19 May 1999 17:53:46 GMT
From: phelanp@aol.com.gov.zx (PhelanP)
Subject: Re: Regex match hash key?
Message-Id: <19990519135346.21438.00003789@ng-fi1.aol.com>
grep /^D/ keys %friends
...will return a list (array) of the keys of the %friends hash that match the
regexp.
>Is there a perl builtin, or efficient module function, which will let me
>find out if any keys in a hash match a regular expression?
==========
I detest SPAM, and boycott the SPAMmers. Send me ads for your competitors!
(my real email address ends in .com)
------------------------------
Date: Wed, 19 May 1999 13:58:24 -0500
From: "k.c. hemelstrand" <kc@dakotaairparts.com>
Subject: We are Looking for Perl Programmer with experience with DBI
Message-Id: <37430967.0@207.70.233.1>
Contact Wes Henry at 701-271-9111 or email wes@avsupport.com
Thanks in advance
------------------------------
Date: Wed, 19 May 1999 14:04:56 -0400
From: Steve Farris <nlymbo@mindspring.com>
Subject: Re: XML::XQL
Message-Id: <3742FD48.E5AC83C2@mindspring.com>
Arved Sandstrom wrote:
>
> In article <3741C660.258048D7@mindspring.com>, Steve Farris
> <nlymbo@mindspring.com> wrote:
>
> > Does anyone have some code samples using the XML::XQL module.
> > Having trouble building queries and accessing element contents.
> > Thanks!
>
> I think you must have overlooked Enno's tutorial on the use of same.
>
> Arved
I looked at it, and got it to work up to a point, but the real problem
is that I don't know which method allows access to the *data* inside
the tags returned by the query. For instance,
use XML::XQL;
use XML:;XQL::DOM;
$parser = new XML::DOM::Parser;
$doc = $parser->parserfile("xmlstuff");
$expr = shift || "//author";
$query = new XML::XQL::Query (Expr => $expr);
@result = $query->solve ($doc);
-------
OK, at this point, @result will contain hash references, one for each
author tag found. the problem i am having is getting at the actual
data contained in the author tag. It's a serious OO deficiency on my
part, but one i am trying to overcome. Gracias para todo ayuda!
------------------------------
Date: Wed, 19 May 1999 12:17:13 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Y2K. localtime(time)
Message-Id: <3742e3cd.0@usenet.fccj.cc.fl.us>
[Mailed and Posted]
----------
In article <slrn7k5k5f.559.fl_aggie@thepentagon.com>,
fl_aggie@thepentagon.com (I R A Aggie) wrote:
> On 19 May 1999 06:23:46 -0600, Daniel Grisinger
> <dgris@moiraine.dimensional.com>, in
> <m3n1z1qmct.fsf@moiraine.dimensional.com> wrote:
>
> [about Matt's script archive]
>
> + Maybe someday somebody with a clue will reimplement those
> + dumb little programs.
>
> Who has time? I've thought about it, but then there are a few dozen
> more interesting pet projects I haven't gotten around to doing, either.
>
> James
OK, I am interested in helping.
Which ones do you find more worthwhile to rewrite ?
(Some should be dumped and started over...)
IMHO,
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: Wed, 19 May 1999 12:19:14 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Y2K. localtime(time)
Message-Id: <3742e444.0@usenet.fccj.cc.fl.us>
[Mailed and Posted]
----------
In article <3742d5bb@newsread3.dircon.co.uk>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:
> I R A Aggie <fl_aggie@thepentagon.com> wrote:
>> On 19 May 1999 06:23:46 -0600, Daniel Grisinger
>> <dgris@moiraine.dimensional.com>, in
>> <m3n1z1qmct.fsf@moiraine.dimensional.com> wrote:
>>
>> [about Matt's script archive]
>>
>> + Maybe someday somebody with a clue will reimplement those
>> + dumb little programs.
>>
>> Who has time? I've thought about it, but then there are a few dozen
>> more interesting pet projects I haven't gotten around to doing, either.
>>
>
> Maybe we ought to post bits of the code (or even the whole thing :) at the
> weekend and do a group rewrite ...
OK, I am interested in helping.
Which ones do you find more worthwhile to rewrite ?
(Some should be dumped and started over...)
IMHO,
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
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 5726
**************************************