[18228] in Perl-Users-Digest
Perl-Users Digest, Issue: 396 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 2 09:05:46 2001
Date: Fri, 2 Mar 2001 06:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983541914-v10-i396@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 2 Mar 2001 Volume: 10 Number: 396
Today's topics:
Re: Bug report: splice/stringification (Martien Verbruggen)
Re: compile probem (URGENT) <alan.carter@flytxt.com>
Re: Display Delay in Perl? (Martien Verbruggen)
Re: flock and close with empty read strangeness <flavell@mail.cern.ch>
Re: flock and close with empty read strangeness (Anno Siegel)
Re: flock and close with empty read strangeness <flavell@mail.cern.ch>
Re: Here is the script i'm working on = internal server <flavell@mail.cern.ch>
Re: How the CLPM turns (Mark Jason Dominus)
Re: How the CLPM turns (Mark Jason Dominus)
Re: How the CLPM turns (Bernard El-Hagin)
milliseconds <awolst@lodderapplicaties.nl>
Re: milliseconds <mkuin@globalrangers.com>
multiple database serving? <daniel.heiserer@bmw.de>
Para mode and <STDIN> <stephen@twocats.dont-spam.demon.co.uk>
Re: Para mode and <STDIN> (Anno Siegel)
Re: Para mode and <STDIN> <stephen@twocats.dont-spam.demon.co.uk>
Re: Para mode and <STDIN> (Anno Siegel)
passing quoted string from ksh to perl henk_bonenkamp@sonymusic.com
Re: passing quoted string from ksh to perl (Anno Siegel)
Re: Perl, Cookies, and Apache. <parrot0123@yahoo.ca>
Re: print "</tr><tr>" vs. print $tr (Martien Verbruggen)
Re: print using () functions and lists (Anno Siegel)
Problem with unsubscribe script. I'l take it from the b <fabian@markisspecialisten.com>
Re: What is \cM ? <pne-news-20010302@newton.digitalspace.net>
Win32::Internet Passive-FTP <ah@datapharm.de>
Re: Win32::Internet Passive-FTP <yeah.yeah@gmx.net>
Re: Win32::Internet Passive-FTP <ah@datapharm.de>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 2 Mar 2001 23:21:36 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Bug report: splice/stringification
Message-Id: <slrn99v42g.pa0.mgjv@martien.heliotrope.home>
On Fri, 02 Mar 2001 02:46:21 GMT,
Joseph Pepin <jdpepin@optonline.net> wrote:
> "Abigail" <abigail@foad.org> wrote in message
> news:slrn99pjj4.9a7.abigail@tsathoggua.rlyeh.net...
>>
>> This problem has been fixed in 5.6.1. Use the email address
> perlbug@perl.org.
>>
>
> Phew! Sorry to cause so much trouble! Thanks, Martien, for all your
> efforts.
Not your fault :)
Martien
--
Martien Verbruggen |
Interactive Media Division | life ain't fair, but the root
Commercial Dynamics Pty. Ltd. | password helps. -- BOFH
NSW, Australia |
------------------------------
Date: Fri, 2 Mar 2001 11:13:30 -0000
From: "Alan Carter" <alan.carter@flytxt.com>
Subject: Re: compile probem (URGENT)
Message-Id: <qaLn6.231$jo4.1075@news.uk.colt.net>
Ok.. okk..
I thought i may just be a simple easy to fix problem... I am now
transcribing to C..
I am on a very tight schedual..........
thanks for your sympathetic input.
"Gwyn Judd" <tjla@guvfybir.qlaqaf.bet> wrote in message
news:slrn99ur10.6ko.tjla@thislove.dyndns.org...
> I was shocked! How could Alan Carter <alan.carter@flytxt.com>
> say such a terrible thing:
> >Anyone have any ideas out there? I am getting this error when trying to
> >compile my perl script! I am clue-less the only thing is that I am use
the
> >"use Socket;" in the code. Should this compile. The reason I am doing
this I
> >because the script in question is being run about 20 times a second, and
i
> >am trying to bring down the startup time, is there any other way I might
> >achive this?
>
> Well if it's an urgent problem then by the time you get this you'll
> probably already have been fired. That said I want to congratulate you
> on winning this weeks "comp.lang.perl.misc's most useless problem
> description" award. Thanks for enriching all of our lives like this,
> please do come again (hopefully with some actual code for us to
> laugh^H^H^H^Hook at).
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> For violence, like Achilles' lance, can heal the wounds it has inflicted.
> -Frantz Fanos, "The Wretched of the Earth"
------------------------------
Date: Fri, 2 Mar 2001 23:43:31 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Display Delay in Perl?
Message-Id: <slrn99v5bi.pa0.mgjv@martien.heliotrope.home>
On 1 Mar 2001 11:56:26 GMT,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
> Come to think of it, I seem to remember there is a simple way to tell
> if a builtin can be overridden, short of testing if it works. Can
> someone remind me, or am I dreaming?
> Anno
End of last year, Tom Christiansen posted an article, with a reference
to the Cookbook, on how to do that. Interestingly enough, he was
responding to you, and the question asked was very similar :)
I don't have that article in my spool anymore, and I don't seem to be
able to coax the new groups.google.com into telling me what the
message-id was, so... I'll just post the headers here that google does
show me:
> From: Tom Christiansen (tchrist@perl.com)
> Subject: Re: overriding 'print'
> Newsgroups: comp.lang.perl.misc
> Date: 2000-12-20 07:47:45 PST
He was responding to <91qg5u$mku$1@lublin.zrz.tu-berlin.de>. You can use
this message id to find your article, and then look at the whole thread.
Martien
--
Martien Verbruggen |
Interactive Media Division | Unix is user friendly. It's just
Commercial Dynamics Pty. Ltd. | selective about its friends.
NSW, Australia |
------------------------------
Date: Fri, 2 Mar 2001 11:59:01 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: flock and close with empty read strangeness
Message-Id: <Pine.LNX.4.30.0103021146460.10676-100000@lxplus003.cern.ch>
On 2 Mar 2001, Anno Siegel wrote:
> According to ZepHead <groovyt@erols.com>:
> > should you use a flock with unlock if your next call is just going to be a
> > close? i read that it causing a race condition???
> > Does close flush the cache and unlock always?
>
> Yes and yes.
Clarification please: are you saying "yes, you _should_ unlock
explicitly, directly before close" ???
> Close flushes all buffers that were assigned on open()
> (it wants to de-allocate them). It also releases all locks on the
> filehandle, since the filehandle is about to go away.
So you seem to be agreeing that an unlock directly before the close
is pointless.
I _can_ understand why older versions of FAQ5 say DON'T unlock at this
point, and that's what I was re-iterating yesterday. What I DON'T yet
understand is why more-recent versions of FAQ5 not only take away that
dire warning (which is understandable, now that the unlock has been
made harmless) but even insert an explicit unlock call directly before
the close (which seems to me to be pointless, as well as being
unnecessarily incompatible with earlier versions of Perl).
I have to admit I hadn't noticed that discrepancy until after I'd been
posting on the related thread yesterday - and I'm a bit surprised that
no-one has taken me to task yet by citing recent versions of FAQ5.
(One might incidentally ask oneself why www.perl.com is still offering
an obsolete set of Perl docs on the web...).
> This is one of the advantages of flock() over ersatz lock mechanisms
> using lock files in the file system: When a process goes away, its
> filehandles go away and so do the locks it holds. There are no
> stale locks.
So I'm puzzled why you apparently answered "yes" to the question of
'should you use unlock directly before close?'.
The answer to a different question, 'can you safely use unlock
directly before close' would seem to be 'yes, in recent versions of
Perl'. But the answer to 'should you' seems to be 'it's pointless' -
so why do it? I'm confused.
all the best
------------------------------
Date: 2 Mar 2001 11:54:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: flock and close with empty read strangeness
Message-Id: <97o1l2$mh4$1@mamenchi.zrz.TU-Berlin.DE>
According to Alan J. Flavell <flavell@mail.cern.ch>:
> On 2 Mar 2001, Anno Siegel wrote:
>
> > According to ZepHead <groovyt@erols.com>:
> > > should you use a flock with unlock if your next call is just going to be a
> > > close? i read that it causing a race condition???
> > > Does close flush the cache and unlock always?
> >
> > Yes and yes.
>
> Clarification please: are you saying "yes, you _should_ unlock
> explicitly, directly before close" ???
You're right, that needs clarification. "Yes and yes" is a poor
reply to a paragraph containing four questions (and five question
marks).
I meant to say: "Yes, close flushes the buffers." and "Yes, it
always unlocks if there is a lock."
> > Close flushes all buffers that were assigned on open()
> > (it wants to de-allocate them). It also releases all locks on the
> > filehandle, since the filehandle is about to go away.
>
> So you seem to be agreeing that an unlock directly before the close
> is pointless.
Yes, and I meant to state that explicitly but must have lost track.
Unlocking a filehandle and leaving it open when the file needs a
lock is less than clear. It is also dangerous when you don't know
which version of perl will run your program and may prove more
dangerous later when an unsuspecting maintainer uses the filehandle
that is invitingly open.
> I _can_ understand why older versions of FAQ5 say DON'T unlock at this
> point, and that's what I was re-iterating yesterday. What I DON'T yet
> understand is why more-recent versions of FAQ5 not only take away that
> dire warning (which is understandable, now that the unlock has been
> made harmless) but even insert an explicit unlock call directly before
> the close (which seems to me to be pointless, as well as being
> unnecessarily incompatible with earlier versions of Perl).
I tend to agree. The standard procedure should be to leave the
unlocking to close() (and close as soon as the file is no longer
needed). The explicit unlock in the FAQ doesn't serve a purpose.
In fact, I find it impossible to think of a scenario where you
would *want* to unlock a file at some point and go on using the
filehandle when the lock was necessary in the first place. If
anything, these situations must be pretty peculiar.
[snip]
> So I'm puzzled why you apparently answered "yes" to the question of
> 'should you use unlock directly before close?'.
>
> The answer to a different question, 'can you safely use unlock
> directly before close' would seem to be 'yes, in recent versions of
> Perl'. But the answer to 'should you' seems to be 'it's pointless' -
> so why do it? I'm confused.
No you aren't, or if you are it's only because my post was confusing.
Your last paragraph sums it up perfectly.
Anno
------------------------------
Date: Fri, 2 Mar 2001 14:35:15 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: flock and close with empty read strangeness
Message-Id: <Pine.LNX.4.30.0103021433190.10676-100000@lxplus003.cern.ch>
On 2 Mar 2001, Anno Siegel wrote:
> > The answer to a different question, 'can you safely use unlock
> > directly before close' would seem to be 'yes, in recent versions of
> > Perl'. But the answer to 'should you' seems to be 'it's pointless' -
> > so why do it?
[...]
> Your last paragraph sums it up perfectly.
Thanks! (that's a relief ;-)
------------------------------
Date: Fri, 2 Mar 2001 14:32:58 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Here is the script i'm working on = internal server error
Message-Id: <Pine.LNX.4.30.0103021407310.10676-100000@lxplus003.cern.ch>
On Fri, 2 Mar 2001, John W. Krahn wrote:
> Maybe I'm reading perlopentut wrong but it says that:
> open(FH, ">> $path");
> is equivalent to:
> sysopen(FH, $path, O_WRONLY | O_APPEND | O_CREAT);
Well, they're two ways of addressing the same requirement.
I made a mistake, it's true.
> where O_WRONLY apparently means _write only_
This can be achieved without resorting to sysopen, if one uses an open
with "+>>". Must admit that I overlooked the missing "+" in the
proffered code. But changing it to "<" , as you did, was taking them
further away from a good answer; however, that doesn't change the fact
that I owe you both an apology for carelessness. I should've cited
the FAQ and left it at that, instead of trying detailed discussion.
> The OP probably wanted:
> open (FILE, "+<" . $file)
With "+<" it's impossible to make the procedure safely self-starting,
i.e creating and locking the file safely if it doesn't already exist.
By means of an unreasonably complex work-around it might be feasible
to avoid that trap, but the approach suggested in FAQ5 is a sysopen
with O_RDWR|O_CREAT
An ordinary open with "+>>" followed by a seek can actually achieve
the same effect, and this was what I was trying to get at in my
earlier f'up. I don't know what the respective portability issues
are, to tell the truth. I suppose I was just trying to minimise the
number of changes relative to the original.
all the best
------------------------------
Date: Fri, 02 Mar 2001 13:06:20 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How the CLPM turns
Message-Id: <3a9f9acb.4af8$1fd@news.op.net>
In article <slrn99mn0h.n9t.bernard.el-hagin@gdndev32.lido-tech>,
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
>Mark-Jason Dominus:
>
>You could change the perl source code to always sort arrays when you
>print them.
I got a big laugh out of this, because it wasn't what I expexcted to
see, and it really is quite apt. But if I did say this, I'd probably
also say something like:
...I think you would want to make the change in the vicinity
of doop.c:675, but I can't quite see how to do it.
(Which sounds as though it might be useful advice if you were really
trying to do that, but turns out not to be very helpful at all.)
Another possibility is:
...I submitted a patch to this effect back in 1998, but
Sarathy called me a fool and refused to include it.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Fri, 02 Mar 2001 13:10:08 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: How the CLPM turns
Message-Id: <3a9f9baf.4b10$43@news.op.net>
In article <3a9f9acb.4af8$1fd@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>If I did say this, I'd probably also say something like:
And then I'd probably follow up to my own article with an embellishment.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Fri, 2 Mar 2001 13:43:16 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: How the CLPM turns
Message-Id: <slrn99v8r7.o1m.bernard.el-hagin@gdndev32.lido-tech>
On Fri, 02 Mar 2001 13:10:08 GMT, Mark Jason Dominus <mjd@plover.com> wrote:
>
>In article <3a9f9acb.4af8$1fd@news.op.net>,
>Mark Jason Dominus <mjd@plover.com> wrote:
>>If I did say this, I'd probably also say something like:
>
>And then I'd probably follow up to my own article with an embellishment.
LOL!
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JaPh`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Fri, 2 Mar 2001 12:10:08 +0100
From: "Arthur Wolst" <awolst@lodderapplicaties.nl>
Subject: milliseconds
Message-Id: <97nv3a$1fl$1@porthos.nl.uu.net>
Hello,
I'm testing the speed of DB access with different servers/scripts/OS
right now I'm testing Apache -> Perl -> COM -> BDE -> Paradox on Win98,
but I can't find a function to retrieve the exact system time (with
millisecs). I
need this to calculate the time difference. There is a function
Win32::GetTickCount
but it's way not accurate enough. When I Sleep(0.750), the second
GetTickCount
delivers the same millisecs as the first, Only when I Sleep 1 sec, there's a
differerence
in the milliseconds of the return value!?!?!?!
I know the same function on WinNT is more accurate, but still nog good
enough.
Is there any other function available to get the exact time values with
milliseconds?
Thanks in advance,
Arthur
------------------------------
Date: Fri, 2 Mar 2001 12:34:27 +0100
From: "Mark Kuin" <mkuin@globalrangers.com>
Subject: Re: milliseconds
Message-Id: <97o0rd$sqg$1@news1.xs4all.nl>
Try the module Time::HiRes
> Is there any other function available to get the exact time values with
> milliseconds?
------------------------------
Date: Fri, 02 Mar 2001 14:23:55 +0100
From: Daniel Heiserer <daniel.heiserer@bmw.de>
Subject: multiple database serving?
Message-Id: <3A9F9EEB.EF2F2117@bmw.de>
Hi,
I have the following problem:
1) I need a very simple database
2) I need something which manages my database, while
multiple processes try to read and write data from and
to the database.
In detail one process (Ai) asks the DBmanager and
waits for an answer. The DBmanager stores the request,
forwards the question to another process (Bi), needs
to wait for this process answer, stores it on the
database and forwards it to the requesting process (Ai) back.
I thought of using perl as the DBmanager and Berkeley-DB
for the database, as I have experience with both.
What I do not know is how my perl-process who takes
care of the database can manage all these requests,
because ALL processs, (A0), (A1), (A2), ... (B0), (B1),..
etc and the perl-process, itself must STAY ALIVE all
the time during hundreds or thousands of requests.
Can I do this with perl? How?
(all processes Ai,Bi can read from stdin and
write to stdout.
They are also capable of implementing own
C-routines (only if necessary)).
Makes pvm here sense?
Also there might be third processes (Ci) which try to
read from the database.
The number of (B) and (A) processes is probably in the
order of 10.
If my 'concept' is wrong what would someone suggest?
thanks a lot
daniel
--
Mit freundlichen Gruessen
Daniel Heiserer
--------------------------------------------------------------
Dipl.-Phys. Daniel Heiserer, BMW AG, Knorrstrasse 147, 80788 Muenchen
Abteilung EK-20
Tel.: 089-382-21187, Fax.: 089-382-42820
mailto:daniel.heiserer@bmw.de
Lageplan Standort FIZ:
http://www.stadtplandienst.de/query?ORT=M&STR=Knorrstr.&HNR=147
------------------------------
Date: Fri, 2 Mar 2001 11:23:18 -0000
From: "Stephen Collyer" <stephen@twocats.dont-spam.demon.co.uk>
Subject: Para mode and <STDIN>
Message-Id: <983532801.3325.0.nnrp-14.9e98901a@news.demon.co.uk>
With Perl 5.005_03 on both Linux and NT, setting paragraph mode
with $/ = '' seems to have no effect on <STDIN> but works fine
with <FILE> where FILE is a filehandle opened on a file. Thus:
$/ = '';
while (<STDIN>)
{
print ">$_<";
}
reads for ever, and does not recognise a run of blank lines as
a terminator, but:
$/ = '';
open FILE, 'file.txt';
while (<FILE>)
{
print ">$_<";
}
works fine.
Is this a known limitation of para mode and STDIN ? If so, it doesn't
seem to be documented. Or a known bug in Perl 5.005_03 ?
Or idiocy on my behalf ?
Steve Collyer
Netspinner Ltd.
------------------------------
Date: 2 Mar 2001 12:12:20 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Para mode and <STDIN>
Message-Id: <97o2n4$pjs$1@mamenchi.zrz.TU-Berlin.DE>
According to Stephen Collyer <stephen@twocats.dont-spam.demon.co.uk>:
> With Perl 5.005_03 on both Linux and NT, setting paragraph mode
> with $/ = '' seems to have no effect on <STDIN> but works fine
> with <FILE> where FILE is a filehandle opened on a file. Thus:
>
> $/ = '';
> while (<STDIN>)
> {
> print ">$_<";
> }
>
> reads for ever, and does not recognise a run of blank lines as
> a terminator, but:
>
> $/ = '';
> open FILE, 'file.txt';
> while (<FILE>)
> {
> print ">$_<";
> }
>
> works fine.
>
> Is this a known limitation of para mode and STDIN ? If so, it doesn't
> seem to be documented. Or a known bug in Perl 5.005_03 ?
There is no such limitation and I'd expect a bug of that caliber
would be known by now. Please show a bit of your input file.
> Or idiocy on my behalf ?
To cover *that* base, please confirm that you ran the STDIN example
as "./script <file.txt" :)
Anno
------------------------------
Date: Fri, 2 Mar 2001 12:24:22 -0000
From: "Stephen Collyer" <stephen@twocats.dont-spam.demon.co.uk>
Subject: Re: Para mode and <STDIN>
Message-Id: <983535987.4594.0.nnrp-14.9e98901a@news.demon.co.uk>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:97o2n4$pjs$1@mamenchi.zrz.TU-Berlin.DE...
> There is no such limitation and I'd expect a bug of that caliber
> would be known by now.
So would I which is why I expect ..
>> .. idiocy on my behalf
>
> To cover *that* base, please confirm that you ran the STDIN
> example as "./script <file.txt" :)
Sorry, can't do that, as I ran it like this:
$ ./script
expecting that I could type merrily away to standard input
and when I typed a couple of newlines, I'd get to see my
paragraph input.
Now I suspect what is happening is this.
1. When $/ = "\n", <STDIN> reads from standard input using
line-at-a-time mode. Thus when you type a newline, <STDIN>
returns.
2. When $/ = '', Perl puts standard input into fully-buffered
mode and looks though the buffer for a "\n\n" string - however
you won't get any data into the script until the input buffer is
filled (1K or whatever).
Anyone familiar enough with perl's guts to confirm this ?
Steve Collyer
Netspinner Ltd
>
> Anno
------------------------------
Date: 2 Mar 2001 12:55:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Para mode and <STDIN>
Message-Id: <97o58v$sto$1@mamenchi.zrz.TU-Berlin.DE>
According to Stephen Collyer <stephen@twocats.dont-spam.demon.co.uk>:
>
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:97o2n4$pjs$1@mamenchi.zrz.TU-Berlin.DE...
>
> > There is no such limitation and I'd expect a bug of that caliber
> > would be known by now.
>
> So would I which is why I expect ..
>
> >> .. idiocy on my behalf
> >
> > To cover *that* base, please confirm that you ran the STDIN
> > example as "./script <file.txt" :)
>
> Sorry, can't do that, as I ran it like this:
>
> $ ./script
>
> expecting that I could type merrily away to standard input
> and when I typed a couple of newlines, I'd get to see my
> paragraph input.
Ah, so the question isn't really about paragraph mode and STDIN,
it's about paragraph mode and tty's.
> Now I suspect what is happening is this.
>
> 1. When $/ = "\n", <STDIN> reads from standard input using
> line-at-a-time mode. Thus when you type a newline, <STDIN>
> returns.
>
> 2. When $/ = '', Perl puts standard input into fully-buffered
> mode and looks though the buffer for a "\n\n" string - however
> you won't get any data into the script until the input buffer is
> filled (1K or whatever).
>
> Anyone familiar enough with perl's guts to confirm this ?
The contents of $/ don't influence buffering on the input filehandle.
It's magical, but not *that* magical.
Buffering may have to do with what you have observed, but it's
output buffering. If you set $| = 1, you'll get a clearer image.
Doing that, you will observe there *is* a quirk with reading
paragraphs from a tty. A sequence of newlines is only recognised
when the first line of the next paragraph (or the final EOF) is
ready to be read. This, however, is quite understandable: $/ = ''
means that any sequence of two or more "\n" ends a paragraph.
This implies that all trailing "\n" belong to the preceding
paragraph, and this can only be recognized when something other
than a "\n" is seen.
It that isn't acceptable you can either set $/ = "\n\n" and work
with the quirks of *that*, or go back to line input and assemble
paragraphs yourself.
Anno
------------------------------
Date: 2 Mar 2001 11:16:10 GMT
From: henk_bonenkamp@sonymusic.com
Subject: passing quoted string from ksh to perl
Message-Id: <97nvdq$9re$1@news.netmar.com>
Hiya, I'm writing a frontend to the ps command in perl. This frontend is
called from a ksh shell. The arguments I'm passing to the ps command from the
frontend are the same arguments I've given to the frontend. It's possible
that those arguments contain a double quoted string.
As far as I can see the double quotes are removed from the arguments by the
ksh. How/where can I pick up the arguments including the double quotes
without using the .sh_history file or backslashes to escape the special
meaning of the double quotes?
Thanks Henk
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: 2 Mar 2001 12:25:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: passing quoted string from ksh to perl
Message-Id: <97o3fk$pjs$2@mamenchi.zrz.TU-Berlin.DE>
According to <henk_bonenkamp@sonymusic.com>:
> Hiya, I'm writing a frontend to the ps command in perl. This frontend is
> called from a ksh shell. The arguments I'm passing to the ps command from the
> frontend are the same arguments I've given to the frontend. It's possible
> that those arguments contain a double quoted string.
>
> As far as I can see the double quotes are removed from the arguments by the
> ksh. How/where can I pick up the arguments including the double quotes
> without using the .sh_history file or backslashes to escape the special
> meaning of the double quotes?
The quotes in the original arguments are gone when you see them, but
their effect isn't lost: A quoted bunch of words appears as only one
element in @ARGV whereas normally each word makes up one element.
So you have a chance to reconstruct the quotes if necessary.
Anno
------------------------------
Date: Fri, 02 Mar 2001 13:13:11 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: Perl, Cookies, and Apache.
Message-Id: <H%Mn6.352072$JT5.11500749@news20.bellglobal.com>
Bart Lateur <bart.lateur@skynet.be> wrote in message
news:peru9t09plgcefuts70esb11st8glb9b90@4ax.com...
>
> Allow me to disagree. It's only still readable if you're reading a whole
> thread in one go. If it's been days since you've read the previous
> message, you'll have to read the quoted part first, anyway, and then it
> becomes annoying (spaghetti reading).
>
You don't need my permission to disagree - it's a free world :)
However, I still disagree with the original statement. I've been messaging
for years, and I've never had a problem reading 'jeopardy-style', nor have
any of my friends online or on BBS's ever complained about decreased
readability of posts depending on the quoting arrangements.
Newsgroups are the only place I've come across where this has been an issue.
I've been told that in the early days there were much fewer users on the
newsgroups and that conditions were much stricter. I guess people got used
to things in a certain way and have trouble adjusting when something
different happens.
I was surprised originally to find out about this - but if people here find
it easier to read that way, it's really no biggie for me to accomodate them,
even if I don't share their ideas about proper quoting arrangements.
------------------------------
Date: Fri, 2 Mar 2001 23:51:05 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: print "</tr><tr>" vs. print $tr
Message-Id: <slrn99v5pp.pa0.mgjv@martien.heliotrope.home>
On Wed, 28 Feb 2001 16:26:08 -0700,
Stan McCann <stan_no_spam_for_me@alamo.nmsu.edu> wrote:
> "Alan J. Flavell" wrote:
>>
>> It's a normal courtesy to the regulars on any usenet group to
>> familiarise yourself with their FAQs first. Nobody minds if you
>> missed something that you needed, but at least if you show some
>> evidence of having tried, you'll command a lot more sympathy.
>
> I do not need lessons in usenet etiquette, I'm new to perl, not
> usenet.
That doesn't show.
> You seem to be the only one that has a problem with my post.
Only because my newsreader habitually scores down subjects that have
anything in them that looks like it may be HTML. I also score down posts
that have the string 'spam' in the From: field. Your posts qualified for
bot. It was invisible to me. Alan's post made the thread visible to me
again, otherwise I might have commented about it. Or maybe not. But I do
agree with him, just for the record, and becase you seem to think that
silence means that there is no dissent with your posts. It doesn't mean
that.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: 2 Mar 2001 11:07:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: print using () functions and lists
Message-Id: <97nut5$bj8$1@mamenchi.zrz.TU-Berlin.DE>
According to Alun Moon <alun.moon@unn.ac.uk>:
> I had a little discussion with a colleague recently concerning
> the use of
> print("hello world\n");
> rather than
> print "hello world\n";
>
> He was intending to use the former () to teach students hew to perl.
> I felt that the later was better, as seen in the perldocs and the
> Camel book(s) (Leaning Perl, Programming Perl).
>
> I was concerned that there were side effects of using () that
> were bad habits to teach students.
>
> Having read through the docs perlfunc and Programming Perl, I'm a little
> unclear.
>
> The section on Terms and List Operators (pg 77) implies that there
> are effects of using () in the print, making it a function rather
> that a list operator. But in the back (pg 548) it says ``if in
> doubt perenthisise''.
>
> I'm farly convinced I was right to suggest teaching print without
> () was right. Was I?
>
> What exactly is the effect of using () on not in print (and other
> operators)? I'm still not clear having read the books and docs.
Parentheses around the arguments of a list operator never change its
behavior. They may change what the operator considers its arguments,
that is disambiguate an expression.
Here is an example (note that it's not "print" but "join" that
needs its arguments delimited):
Printing the elements of an array with commas between them is
sometimes done this way:
print join( ", ", @array), "\n";
If you were to leave off the parentheses around the arguments of
"join":
print join ", ", @array, "\n"; # wrong!
join would gobble up the final "\n" and include it in its list of
things to join. This is not what's intended.
Otherwise, writing parentheses or not is merely a stylistic option.
There is a clear tendency over the last few years to use fewer and
fewer parens, but that's more like a fashion trend than a statement
about good coding practice.
Anno
------------------------------
Date: Fri, 02 Mar 2001 13:31:21 GMT
From: "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
Subject: Problem with unsubscribe script. I'l take it from the begining.
Message-Id: <JgNn6.16325$Qb7.2665306@newsb.telia.net>
This script should delete e-mail adresses from my e-mail list, using e-mail
data from form.
I'l get no server error messages but no submitted e-mail addresses deletes.
The form is named remove.htm and looks like this:
<form action="../cgi-markisspecialisten/remove.pl" method="POST">
<p>Email Address: <input type="text" size="20" name="address">
</p>
<input type="submit" value="Skicka">
</form>
The script is named remove.pl and looks like this:
#!/usr/bin/perl -w
read(STDIN, $email, $ENV{'CONTENT_LENGTH'}); ## I guess that this line reads
the e-mail address from the form *
use strict;
use Fcntl qw(:flock);
print "Content-type: text/html\n\n";
my $file = '/home/markisspecialisten/www/guestmail.htm';
my $lockfile = "$file.lock";
open LOCKFILE, ">>$lockfile" or die "cannot open lock file $lockfile: $!";
flock(LOCKFILE, LOCK_EX) or die "cannot lock file exclusively: $!";
open FILE, "<$file" or die "cannot open $file for input: $!";
my @emailfile = <FILE>;
close (FILE) or die "cannot close message file: $!";
open FILE, ">$file" or die "cannot open $file for output: $!";
my $email = 'someone@somewhere'; ## * So, wath is this?
my $line;
foreach $line (@emailfile)
{
if ($line !~ /^\Q$email/o) ## * And search for it here
{
print FILE $line; ## * And delete it here
}
}
close (FILE) or die "cannot close final message file: $!";
close (LOCKFILE) or die "cannot close lock file: $!";
# (end)
The e-mail list is named mail.htm and looks like this:
<!--begin-->
someone@somewhere.com<br>
someone2@somewhere.com<br>
someone3@somewhere.com<br>
someone4@somewhere.com<br>
------------------------------
Date: Fri, 02 Mar 2001 12:07:53 +0100
From: Philip Newton <pne-news-20010302@newton.digitalspace.net>
Subject: Re: What is \cM ?
Message-Id: <ofvu9tkdd234hlea65inelokcee70visn6@4ax.com>
On 1 Mar 2001 21:01:52 GMT, Eli the Bearded <elijah@workspot.net>
wrote:
> In comp.lang.perl.misc, J Garcia <garcia868@yahoo.com> wrote:
> > I know that \c[ is the control character, but what is
> > \cM? thanks for helping out.
>
> \c{FOO} is control character {FOO}. So \c[ is <ESC> and
> \cM is <CR>. In general, {FOO} is the ascii char of the
> control char plus 64. \c? is one exception, it is minus
> 64. Lower case letters are treated as uppercase ones by
> perl for this.
In other words, in general, {FOO} is chr(ord(control char) ^ 64),
right? (This would account for the "discrepancy" between
"add/subtract".)
It also seems to work for other things, for example "\c=" is "}", and
"\c}" is "=".
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Fri, 02 Mar 2001 12:17:12 +0100
From: Andreas Huber <ah@datapharm.de>
Subject: Win32::Internet Passive-FTP
Message-Id: <3A9F8138.EE3A127@datapharm.de>
Hi,
how can I connect to a ftp server with passive mode?
I try this:
$inet = new Win32::Internet();
$inet->Pasv(1);
if(!($inet->FTP($ftp, $ftp_server, $ftp_login, $ftp_password ))){ ...
but that won't work!
Thanks for help
--
Andreas Huber
Produktion & Entwicklung
Datapharm Netsystems AG
E-Mail: ah@datapharm.de
Tel.: (+49) 89 85 68 4 -202
Fax: (+49) 89 85 68 4 -100
------------------------------
Date: Fri, 02 Mar 2001 13:16:38 +0100
From: Markus Weihrauch <yeah.yeah@gmx.net>
Subject: Re: Win32::Internet Passive-FTP
Message-Id: <97o6fm.1d4.1@ID-35539.user.dfncis.de>
On Fri, 02 Mar 2001 12:17:12 +0100, Andreas Huber <ah@datapharm.de>
wrote:
> how can I connect to a ftp server with passive mode?
# use passive mode to circumvent any firewall issues
$self->{FTPConn} = Net::FTP->new( $self->{Site},
Debug => $DEBUGMODE,
Passive => 1 );
Markus
--
"Quite frankly, teachers are the only profession that teach our children."
Governor George W. Bush, Jr., 9/18/95
------------------------------
Date: Fri, 02 Mar 2001 13:42:24 +0100
From: Andreas Huber <ah@datapharm.de>
Subject: Re: Win32::Internet Passive-FTP
Message-Id: <3A9F9530.186ABFE2@datapharm.de>
> On Fri, 02 Mar 2001 12:17:12 +0100, Andreas Huber <ah@datapharm.de>
> wrote:
> > how can I connect to a ftp server with passive mode?
>
> # use passive mode to circumvent any firewall issues
> $self->{FTPConn} = Net::FTP->new( $self->{Site},
> Debug => $DEBUGMODE,
> Passive => 1 );
>
I need it for IIS (Win32::Internet)
--
Andreas Huber
Produktion & Entwicklung
Datapharm Netsystems AG
E-Mail: ah@datapharm.de
Tel.: (+49) 89 85 68 4 -202
Fax: (+49) 89 85 68 4 -100
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 396
**************************************