[10463] in Perl-Users-Digest
Perl-Users Digest, Issue: 4055 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 23 15:04:18 1998
Date: Fri, 23 Oct 98 12:00:21 -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 Fri, 23 Oct 1998 Volume: 8 Number: 4055
Today's topics:
Re: A CPAN mirror <ckuskie@cadence.com>
Re: Build DBD-Oracle-0.54 on Windows NT xsun1913@my-dejanews.com
deadlock with flock() and open() <reynolds@kcc.nospam.com>
Re: deadlock with flock() and open() <tchrist@mox.perl.com>
Re: deadlock with flock() and open() (Mark-Jason Dominus)
Re: Great Script--won't work <perlguy@technologist.com>
Help - Linux/serial line problem <daj102@york.ac.uk>
Help with tree-like data structure (I think) ()
Re: Help: string variable $patTar in s/$patSrc/$patTar <r_larsen@image.dk>
Re: i just find a whatsnew cgi script <perlguy@technologist.com>
Re: Keith : CreateObject doesn't work via my browser <keithmur@mindspring.com>
Re: Marrying S-Lang and Perl -- boon or blasphemy? (John E. Davis)
MSQL dump from PERL script <edgar@insidewire.com>
Re: Need Help With Win95 Perl Installation ullrich@math.okstate.edu
Re: Opening a newly created file. <perlguy@technologist.com>
Re: Opening a newly created file. <shjmoore@sprynet.com>
Re: Perl & Y2K - booby trap code <jimbo@soundimages.co.uk>
Re: Perl & Y2K - booby trap code (Don Groves)
Re: Pink? Blue? What color _is_ it??? <keithmur@mindspring.com>
Re: Problem with code (David Huggins)
Re: Script displaying IP address and hostnames? pm@oceanway.com
Socket Problem <e.brauer@intershop.de>
Re: Strict and Global Variables <noel.sant@which.net>
Unlocking files after Locking them?? Webby@cryogen.com
Re: Unlocking files after Locking them?? (Larry Rosler)
Re: What's the "best" way to call one Perl script from (Alfred von Campe)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Oct 1998 11:13:04 -0700
From: Colin Kuskie <ckuskie@cadence.com>
To: tmcguiga@my-dejanews.com
Subject: Re: A CPAN mirror
Message-Id: <Pine.GSO.3.96.981023110830.11220C-100000@pdxue150.cadence.com>
[Complementary email sent to tmcguiga@my-dejanews.com]
On Fri, 23 Oct 1998 tmcguiga@my-dejanews.com wrote:
> Anyone know how large is CPAN and what kind of traffic would a mirror be
> expecting?
Check out http://www.perl.com/CPAN/SITES.html for information
about mirroring and size. You'll probably end up contacting
the CPAN administrators: cpan@perl.org.
HTH,
Colin
------------------------------
Date: Fri, 23 Oct 1998 17:40:30 GMT
From: xsun1913@my-dejanews.com
Subject: Re: Build DBD-Oracle-0.54 on Windows NT
Message-Id: <70qf2f$pl8$1@nnrp1.dejanews.com>
In article <70gtvn$31m$1@nnrp1.dejanews.com>,
yzhao@my-dejanews.com wrote:
> Has anyone built DBD-Oracle-0.54 successfully on WindowS NT? When I ran the
> Makefile.PL (see the trace below), it first complained that "ld" (should be
> ... ...
I installed the latest version of Perl on my NT first (download from
http://www.cpan.com/), then built DBI mod and DBD-Oracle-0.54 mod using VC++
5.0.
Xuening Sun
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Oct 1998 17:42:40 GMT
From: "John Reynolds" <reynolds@kcc.nospam.com>
Subject: deadlock with flock() and open()
Message-Id: <01bdfeab$58ba29a0$07221ca5@B19592-WS.kcc.com>
Hello,
I'm experimenting with flock() and open() and it appears that if a file is
locked, an open for write or append just waits. That would appear to open
the door for two scripts to deadlock. e.g.
prog1 :
open(FILE1, ">>file1.txt") or die "can not open file1.txt" ;
flock FILE1, 2 ;
open(FILE2, ">>file2.txt") ;
......more interesting stuff......
prog2 :
open(FILE2, ">>file2.txt") or die "can not open file2.txt" ;
flock FILE2, 2 ;
open(FILE1, ">>file1.txt") ;
......more interesting stuff......
If they both execute at the same time they can both end up waiting on the
other to release the lock on their respective files.
Is there a way to test to see if a file is locked before trying open()?
Thanks for the help!
--
John Reynolds
remove nospam
------------------------------
Date: 23 Oct 1998 18:14:56 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: deadlock with flock() and open()
Message-Id: <70qh30$iqk$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to the despammed address to cited author via email]
In comp.lang.perl.misc, "John Reynolds" <reynolds@kcc.com> (whose name has
been entered into the spamathon page):
:If they both execute at the same time they can both end up waiting on the
:other to release the lock on their respective files.
Yup, we call that a deadly embrace.
:Is there a way to test to see if a file is locked before trying open()?
Not portably.
But it doesn't matter. If process number one says "lock A, then lock B",
but process number two says "lock B, then lock A", you're really going
to have a problem. You cannot acquire two separate lock atomically,
so you'll always be vulnerable to errors in ordering. You must reduce
these to one lock.
Suggestion: lock only a dummy third file, something of a sentinel,
before attempting to access without locks the first two.
There's a reason that universities offer courses in operating systems
and concurrency design, you know. :-)
--tom
--
MSDOS is a Neanderthal operating system -- Henry Spencer
------------------------------
Date: 23 Oct 1998 14:28:46 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: deadlock with flock() and open()
Message-Id: <70qhsu$a4m$1@monet.op.net>
In article <01bdfeab$58ba29a0$07221ca5@B19592-WS.kcc.com>,
John Reynolds <reynolds@kcc.nospam.com> wrote:
>Hello,
>
>I'm experimenting with flock() and open() and it appears that if a file is
>locked, an open for write or append just waits.
That is not the case.
------------------------------
Date: Fri, 23 Oct 1998 17:13:20 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Great Script--won't work
Message-Id: <3630B930.1935C0B6@technologist.com>
William Schroeder wrote:
>
> I downloaded a small "Unix" program that is a "Internet Phone Book". I can't
> get the program to work (spent many hours tweeking and fooling with it).
> I E-mailed the originator of the program but he hasn't replied.
> The program was obtained from a CGI Collection on the web at:
> http://www.itm.com/cgicollection/index.cgi?/page=1&=11&e=20
> The program is called "Internet Phone Book"
> Try the "demo" out see what you think. It's at:
> http://www.selah.net/pbook.html
Yuk! (I just looked at the demo)
Go to http://webreview.com and click on the "Revisiting the Database
Application" link.
It is a "database" application that is EASILY customized and will do
what you are looking to do.
Good luck,
brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Fri, 23 Oct 1998 17:56:01 +0100
From: The Flying Scotsman <daj102@york.ac.uk>
To: The Flying Scotsman <daj102@york.ac.uk>
Subject: Help - Linux/serial line problem
Message-Id: <Pine.SOL.3.95L.981023175112.10932A-100000@mailer.york.ac.uk>
Can you help me with a little problem?
At the radio station here at the Uni of York, we've got a satellite
receiver which spits out ASCII data on a 9600 serial line. I'm trying to
capture this under linux from the COM port (/dev/ttyd0) which has been set
to raw, with the EOF and EOL characters set to undef with stty.
However, PERL does not seem to get the information fast enough from the
line. All I've done is something like:
open (RECEIVER, "cat /dev/ttyd0 |");
while ($line = <RECEIVER>) {
# Parse stuff here
}
But PERL does not seem to get the info. I've watched info come in from
the line but it did not seem to register with PERL at all. The stuff
coming in has lots of control characters in there, but this should not
affect anything, should it?
Can you CC any replies directly to me please?
--DJ
==================== oo00OO00oo ========================
If automobiles had followed the same development
cycle as the computer, a Rolls-Royce would today cost
$100, get a million miles per gallon, and explode once
a year, killing everyone inside.
- Robert Cringely
Douglas Johnston can be contacted at:
Address: Flat 1 Tel: (01904) 638713
25 Park Street (0956) 513229
YORK
YO2 2BQ http://www.york.ac.uk/~daj102
==================== oo00OO00oo ========================
------------------------------
Date: Fri, 23 Oct 1998 18:38:37 GMT
From: jf@home. ()
Subject: Help with tree-like data structure (I think)
Message-Id: <F1AMGE.Bo8@freenet.akron.oh.us>
Hello,
I am attempting to parse my Netscape Communicator 4.5 for Linux bookamarks
file. I want to load the entire file into some data structure for
processing, but I am having trouble thinking about exacly how the records
will be cnstructed.
The code I have will go through the file and remove all the junk
Communicator puts in the file. The file uses the HTML definition list tag
for its structure, so picking out the dl tags and knowing what level of
header we're looking at is easy enough.
My final goal is to create an index which will display the level 1 headings
in a side frame of a web page, and have each heading be a link which will
load up the links and sub-headings in the same frame.
Perhaps I don't need to do what I think I need to do to accomplish this?
Thanks for taking the time to read this.
Here's an example data structure of the bookmarks file.
Toplevel
heading1
link
link
heading1
link
heading2
link
heading2
link
link
heading1
link
link
link
link
--
Jim Foltz <aa204@acorn.net>
------------------------------
Date: Fri, 23 Oct 1998 21:18:53 +0100
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Help: string variable $patTar in s/$patSrc/$patTar
Message-Id: <VA.0000006a.001659ce@octo>
This double posting happened because my software lost the
connection after sending the answer but before it got an
acknowledgement.
Reni
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: Fri, 23 Oct 1998 17:09:50 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: i just find a whatsnew cgi script
Message-Id: <3630B85E.ECC3C5D8@technologist.com>
cutebaby@my-dejanews.com wrote:
>
> someboby have the whatsnew(new) perl cgi script
>
> plz tell me whhere to get
>
> , because my homepage need it
>
ddid uuu ttry http://www.cgi-resources.com ????
> need your help ~
obviously,
they are in the "Perl Scripts" section under "What's New"
hth,
brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Fri, 23 Oct 1998 13:13:32 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Keith : CreateObject doesn't work via my browser
Message-Id: <3630C74C.1A8F6486@mindspring.com>
I'm sure it worked for me because I didn't *need* it to. ;-) Beyond
that, I'm still perplexed.
nicolaslecart@my-dejanews.com wrote:
>
> Hello Keith,
>
> i don't understand why it works with you (you are very lucky ;))) ), even if
> there is a difference between our configuration (i use Win NT 4.0 with
> NES3.5.1 when you use Win95 with MS personal Web server).
>
> I do what you told me , and i can run "a simple CGI script on the same
> *directory*, with the same *file
> type* (like .pl for both) on the
> same *system*, with the same *browser*
> i am trying with my OLE script".
>
> Moreover, the scripts have the same permissions.
>
> The problem in my OLE script is that the CreateObject function can't create
> an Excel application instance :((((((((
>
> Thank you for your help anyway
>
> Regards
>
> Nicolas
>
> In article <362D0CE2.7841184E@mindspring.com>,
> keithmur@mindspring.com wrote:
> > Actually the script works fine on my system (Win95 running MS Personal
> > Web Server; the browser is Netscape 4.06). I take it from your previous
> > postings that you *CAN* run a simple CGI script from a browser. Can you
> > run a simple CGI script on the same *directory*, with the same *file
> > type* (like .pl for both) on the same *system*, with the same *browser*
> > that you're trying with your OLE script? Do the *scripts* have the same
> > permissions (check the file properties)? If so, *I'm* baffled. Let me
> > know.
> >
> >
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Oct 1998 18:35:29 GMT
From: davis@space.mit.edu (John E. Davis)
Subject: Re: Marrying S-Lang and Perl -- boon or blasphemy?
Message-Id: <slrn731j3f.a3b.davis@aluche.mit.edu>
On 23 Oct 1998 16:14:40 GMT, James Palmer <james@tiger-marmalade.com>
wrote:
>Ah, but then the possibility for module extensions are endless..
Since this is a new feature, I would certaintly appreciate feedback
upon the usefulness of this and slang's implementation. I have
already written PGPLOT and CFITSIO modules and used them.
--John
------------------------------
Date: Fri, 23 Oct 1998 13:28:22 -0400
From: "Edgar Sigal" <edgar@insidewire.com>
Subject: MSQL dump from PERL script
Message-Id: <3630bc8b.0@diana.idirect.com>
I need help in creating a script which will call the standard msql dump
program on my server, to output to a text file which I will then be able to
retrive with ftp.
Any help is greatly appreciated
--
-Edgar
330556
edgarnospam@insidewire.com
------------------------------
Date: Fri, 23 Oct 1998 17:54:35 GMT
From: ullrich@math.okstate.edu
Subject: Re: Need Help With Win95 Perl Installation
Message-Id: <70qfss$qhd$1@nnrp1.dejanews.com>
In article <362f5bf0.3383337@news.compuserve.com>,
mwatkins@ia-watkins.com (Mike Watkins) wrote:
> Hi there,
>
> OK, I'm very sorry, but I am new at this. I just downloaded perl and
> I'm not sure if I have a C Complier. I don't think I do, so I
> probably don't.
>
> Anyway, I read the help file and it said to download a GCC Compiler.
> Anyone know where I can download one?
>
> Any help would be much appreciated.
There actually do exist binary (ie already compiled) versions
for Windows 95, suitable for weenies like me and you (hope you noticed
I included myself there). Dunno exactly where to tell you to look,
I got mine off the CD with some book. But they're out there.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Oct 1998 17:03:56 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Opening a newly created file.
Message-Id: <3630B6FC.ADC5D8D2@technologist.com>
How are you opening it? Show us some code...
Typically, when you run CGI programs, they run as whatever user the web
server is set up to run as. When you create a file, it will create one
with the permission of THAT user.
Have you tried opening the file in WRITE mode, and then sending data to
it? Try this snippet:
open (HANDLE,">filename.txt") || die "There was an error opening the
file $!\n";
print HANDLE "Print this in the file...\n";
close(HANDLE);
and see if you have entered anything into the file...
HTH,
brent
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Fri, 23 Oct 1998 12:52:07 -0400
From: Jay Moore <shjmoore@sprynet.com>
Subject: Re: Opening a newly created file.
Message-Id: <3630B436.4DF1CE5D@sprynet.com>
This is a multi-part message in MIME format.
--------------1B3F9CBC5AB67C589D5F74A9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Try
chmod 0755, $filename
or
chmod 0755, 'myfile.txt'
STEPHEN REINGOLD wrote:
> I can have my Perl CgI create and write to a new file, but can't read
> it unless I chmod the new file through telnet. Can I have my Perl CGI
> create AND allow me to read the file?
>
> Thanks much.
> Stephen (sreingol@interlog.com)
--------------1B3F9CBC5AB67C589D5F74A9
Content-Type: text/x-vcard; charset=us-ascii;
name="shjmoore.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Jay Moore
Content-Disposition: attachment;
filename="shjmoore.vcf"
begin:vcard
n:Moore;Jay
tel;work:703.351.5870 x252
x-mozilla-html:TRUE
org:Domain Techonolgies
adr:;;1901 N. Ft Myer Drive;Arlington;VA;;
version:2.1
email;internet:moorejay@netscape.net
title:Senior Unix Systems Engineer
fn:Jay Moore
end:vcard
--------------1B3F9CBC5AB67C589D5F74A9--
------------------------------
Date: 23 Oct 1998 18:08:50 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <u90i7jjdp.fsf@jimbosntserver.soundimages.co.uk>
rsholmes@rodan.syr.edu (Richard S. Holmes) writes:
>
> TFM was part of the problem, not the solution.
>
Sorry, you are wrong. The documentation provided with Perl 5.004 is
very clear about the state of time. Regardless the colour of one's
Camel. As has been repeatedly pointed out here, the ONLY definitive
manual EVER provided for Perl is that which comes with the
source. Read it. Understand it. Use it. That is the way.
If you don't like the way, don't EVER, EVER, EVER place the following
characters together, RTFM. TFM is NOT a Camel. It is POD. Please, do
not become confused. The Camel is a beautiful and most welcome adjunct
to Perl. To POD. It is NOT POD. Remember that and be forgiven. Be
healed.
Whether newbie or hardened professional, TFM is ALWAYS provided. TFM
is always current. TFM is not a book by ORA. It is POD provided with
the source. Read it. Use it. Don't belly-ache.
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: Fri, 23 Oct 1998 10:00:38 -0700
From: see@my.sig (Don Groves)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <MPG.109a561666dff596989734@news.europa.com>
In article <70ogg1$1om$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
says...
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
> :There is an unambiguous way that is also *standard*: ISO 8601:1988.
> :The following is the complete long form:
> :
> :yyyy-mm-dd HH:MM:SS (punctuation is optional)
>
> The day that you ask everyone on the street when they were born and they
> all recite an answer in a form such as that is the day that computer
> programmers should expect to use that form as their unique input and
> output style.
I'll agree when computers can handle the semantics and assumptions of
ordinary human communication. Until then, computers need to handle data
with a bit more precision than humans do.
--
Don Groves (groves_acm_org)
Replace underscores to get my email address
------------------------------
Date: Fri, 23 Oct 1998 13:16:37 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Pink? Blue? What color _is_ it???
Message-Id: <3630C805.D4FEF48E@mindspring.com>
There should be a word for colors just like 'phoneme' is for speech
sounds. 'Chromeme'?
Ben Coleman wrote:
>
> On 21 Oct 1998 21:06:33 GMT, jgd@alpha3.csd.uwm.edu (John G Dobnick) wrote:
>
> > But what's this "blue" thing? Since when did "teal" become "blue"?
> > Have I missed something
>
> Some of us are essentially aesthetically blind. To us, coming up with
> names to describe different shades of blue is a waste of time.
>
> Ben
> --
> Ben Coleman
> Senior Systems Analyst
> TermNet Merchant Services, Inc.
> Atlanta, GA
------------------------------
Date: 23 Oct 1998 13:40:21 -0400
From: bn711@freenet.carleton.ca (David Huggins)
Subject: Re: Problem with code
Message-Id: <87g1cfgosa.fsf@freenet.carleton.ca>
nguyen.van@imvi.bls.com writes:
> I have another problem with filehandle. The following is my code:
<snip>
> I see the changes in STDOUT but there weren't no changes in the files
> (i.e aol_out, msie_out, netscape_out). What are other additional steps that I
> need to do so that I can see the changes in these files. I also don't want to
> change the file names. Your help is appreciated.
Here's a hugely shorter version that probably does what you want:
#!/usr/bin/perl -wpi
use strict;
# default list of parameters (files to munge)
# this operates outside the implicit read-print loop (as in awk)
BEGIN {@ARGV = qw(aol_out msie_out netscape_out) unless @ARGV}
# $_ is, of course, not necessary here
s#(AOL)\s(\d\.\d+)#$1_$2#g;
s#(MSIE)\s(\d\.\d+)#$1_$2#g;
s#(Mozilla)\/(\d\.\d+)#$1_$2#g;
# implicit print to the current file is already provided by -p
print STDOUT;
__END__
The key is the switches on the shebang line:
-p makes Perl act like sed and awk (i.e. it puts an implicit
read-print loop around the script)
-i makes Perl do some magic that makes it look like you're modifying
files in place (read the perlrun(1) man page to find out what it
really does)
-w is good. use it always.
This version is a lot less C-like than your original... I'll leave it
to you to decide whether using Perl's features makes it more concise
or just more obfuscated. As they say, TMTOWTDI :-)
Cheers
--
David Huggins-Daines - bn711@freenet.carleton.ca
PGP public key #63A8B719 on public key servers
fingerprint=4F 38 A2 34 E1 E0 B7 6E C3 DA 6C E3 C6 6A 05 62
------------------------------
Date: Fri, 23 Oct 1998 17:00:18 GMT
From: pm@oceanway.com
Subject: Re: Script displaying IP address and hostnames?
Message-Id: <70qds9$ig9$1@supernews.com>
Wouldn't the simplest way be, to snag this information directly from the
logfile generated by the IIS server program... since all IP no's normally are
stored there in ASCII and therefor aught to be possible to be transferred...
All you need to find out is if the last log is entered at the top or bottom of
the logfile (which you see in the log it self by the timestamp)...:)
Just an idea...
P|M
=========
In article <btay-ya02408000R0407980727270001@news1.nj.home.net>,
btay@nospam.com2000.net wrote:
>Does anybody knows if there's a script written in perl for Windows NT IIS
>4.0 that will display a visitor's IP address and hostname when accessing a
>particular web page such as a web form?
>
>Any help would be appreciated.
>
>Regards,
>
>Bill
>btay@nospam.com2000.net
>
>*Note: When replying, remove "nospam" from the return email address.
------------------------------
Date: Fri, 23 Oct 1998 18:47:24 +0200
From: Eckard Brauer <e.brauer@intershop.de>
Subject: Socket Problem
Message-Id: <3630B31C.3642DF85@intershop.de>
Hi!
There has been a problem with using sockets in a sendmail script
function a few days (weeks) back. I can't remember the exact point, but
we 've had a similar problem with the nearly same script.
I found out that in a context like this:
...
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto)) { return -2;
}
if (!connect(S, pack('Sna4x8', AF_INET, $port, $smtpaddr))) { return -3;
}
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost\r\n";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>\r\n";
...
the socket has been closed for only input for any reason I don't know
after receiving the initial mail server response. This happened only if
I called the function from inside an application; calling the function
from a command line started perl (use blablabla, sendmail;
sendmail(...);) did it everytime I tried.
The solution I found is simple: I dup'ed the socket and used one for
input and one for output:
...
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto)) { return -2;
}
if (!connect(S, pack('Sna4x8', AF_INET, $port, $smtpaddr))) { return -3;
}
open S_OUT, ">&S";
my($oldfh) = select(S_OUT); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; close S_OUT; return -4; }
print S_OUT "helo localhost\r\n";
$_ = <S>; if (/^[45]/) { close S; close S_OUT; return -5; }
print S_OUT "mail from: <$fromaddr>\r\n";
...
This worked for me. BTW: We had the problem only at one of some
different platforms (Reliant-UNIX/svr4). Seems that at least the perl I
built has a side effect of closingone direction of bidirectional
channels with 'select(FILEHANDLE)' in some contexts, at least when
assuming that the response of the mail server is held in an receive
buffer _before_ 'select' is evaluated.
Don't flame me if I'm wrong, I'm not very experienced with perl, but in
the end I can't explain it another way.
"use FileHandle; autoflush S 1;" didn't help, too.
Hope it can help somehow.
------------------------------
Date: Fri, 23 Oct 1998 19:44:04 +0100
From: "Noel Sant" <noel.sant@which.net>
Subject: Re: Strict and Global Variables
Message-Id: <70qivg$qoo$1@nclient1-gui.server.which.net>
OK, so you're saying keep all major subroutines in one or more separate
files and call each file a package (I'll read up about how to do that). I
guess this means the only interface between my main script and the subs is
using arguments and returning status codes? I'd really like to read a
configuration file in my main script (using the IniConf package) and have
the result available to the subs. I suppose I can pass a reference to the
object IniConf creates?
BUT: what does tmtoady mean? Sorry, TMTOWTDI?
Regards,
Noel Sant
Ala Qumsieh wrote in message ...
>
>By far, the best way, in my opinion, is to place all your reusable
>subroutines inside a separate file, also called a module. Then, in
>your script, you can
>
>use Module;
>
>or
>
>use Module qw/sub1 sub2 ../;
>
>This will allow you to use the subroutines defined in Module.pm (if
>properly defined, that is) and prevents too much cluttering of your
>name space.
>
>> So what the devil's a poor programmer to do?
>
>A poor programmer should stare at his console until he memorizes the
>following letters:
>
>"TMTOWTDI"
>
>Does this clear things up a little?
>--
>Ala Qumsieh email: aqumsieh@matrox.com
>ASIC Design Engineer phone: (514) 822-6000 x7581
>Matrox Graphics Inc. (old) webpage :
>Montreal, Quebec http://www.cim.mcgill.ca/~qumsieh
------------------------------
Date: Fri, 23 Oct 1998 18:12:00 GMT
From: Webby@cryogen.com
Subject: Unlocking files after Locking them??
Message-Id: <3630c59d.1021700@news.iaehv.nl>
Hello,
I always use the flock(FILE, "2") command to lock a file after that
I've opened it. But I never use the flock(FILE, "8") command to unlock
the file. Does the file automatically unlock when I close it??
Please let me know!
Best Regards,
Shwerbe
------------------------------
Date: Fri, 23 Oct 1998 10:30:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Unlocking files after Locking them??
Message-Id: <MPG.109a5cfa57f7e855989835@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <3630c59d.1021700@news.iaehv.nl> on Fri, 23 Oct 1998 18:12:00
GMT, Webby@cryogen.com <Webby@cryogen.com> says...
> I always use the flock(FILE, "2") command to lock a file after that
> I've opened it. But I never use the flock(FILE, "8") command to unlock
> the file. Does the file automatically unlock when I close it??
You bet it does; in fact, that's the preferred way to unlock the file.
BTW, what are those quotes doing around your numerical arguments, except
creating strings which the function then turns back into numbers?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 23 Oct 1998 17:54:26 GMT
From: alfred@hw.stratus.com (Alfred von Campe)
Subject: Re: What's the "best" way to call one Perl script from another?
Message-Id: <70qfsi$dt6@transfer.stratus.com>
Daniel Beckham (danbeck@eudoramail.com) wrote:
|>Why not just turn those seperate scripts into functions and use the main
|>script to glue the functions together? If you still want to have the
|>functions in seperate files for re-usability, you can use the require
|>statement to pull the function files into the main script.
Because these other scripts still need to be standalone scripts
that a user can invoke. The script I'm currently writing is a
"super" script if you will that automates our regression process,
but users still need to run tests manually.
As for those who responded that I should use "do", it does indeed
do what I want. I just hadn't noticed or used that function before.
Alfred
--
+------------------------------------------------------------+
| Phone: H: 978.448.6214, W: 508.490.6306, fax: 508.229.4076 \
| Mail: Alfred von Campe, 402 Lowell Road, Groton, MA 01450 \
| Email: alfred@hw.stratus.com \
+----------------------------------+-----------------------------+
| Why is common sense so uncommon? | I'd rather be flying N4381Q |
+----------------------------------+-----------------------------+
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4055
**************************************