[13093] in Perl-Users-Digest
Perl-Users Digest, Issue: 503 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 13 13:07:31 1999
Date: Fri, 13 Aug 1999 10:05:13 -0700 (PDT)
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, 13 Aug 1999 Volume: 9 Number: 503
Today's topics:
Re: Bits and Bytes ... (Bart Lateur)
Re: Compare Two FILES <tchrist@mox.perl.com>
HARASSMENT -- Monthly Autoemail <urielw@tiac.net>
Re: HARASSMENT -- Monthly Autoemail (Jerome O'Neil)
Re: Help with CGI and perl (Steve Linberg)
Re: Looking for a solution to the problem localtime and <Jack.Alexander@digital.com>
Re: Looking for a solution to the problem localtime and <Jack.Alexander@digital.com>
Re: Moving a Perlscript from NT to LINUX <schmickl@magnet.at>
Re: Nastiness contrary to the spirit of perl? (Geoff Joy)
Re: Nastiness contrary to the spirit of perl? (Id Est)
Re: Newbie question <kangas@anlon.com>
Re: Possible Perl Bug or Just Me <uri@sysarch.com>
Re: Possible Perl Bug or Just Me (Malcolm Ray)
Re: problem with ping() in perl <hendrik@doora.ee>
Re: Review for Algo. in Perl <mcking@cajunbro.com>
saving a hash <mdudley@execonn.com>
Re: Sending mail to "QuestionExchange" <flavell@mail.cern.ch>
Re: Sending mail to "QuestionExchange" (Anno Siegel)
Re: Stopping output (Michel Dalle)
Strange trouble with a STRAY CURLY BRACE "}" jsilve1@my-deja.com
Re: Stripping quotes only from HTML tags <mcking@cajunbro.com>
Re: tail equiv. using Perl on Win32 ? <rwatkins@springer-ny.com>
Re: tail equiv. using Perl on Win32 ? (Villy Kruse)
Re: tail equiv. using Perl on Win32 ? <rwatkins@springer-ny.com>
Re: Why use Perl when we've got Python?! <milese@pacbell.net>
Re: Why use Perl when we've got Python?! <milese@pacbell.net>
Re: Why use Perl when we've got Python?! <I.Clarke@strs.co.uk>
Re: Why use Perl when we've got Python?! <skip@mojam.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 13 Aug 1999 16:52:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Bits and Bytes ...
Message-Id: <37b449a1.1136068@news.skynet.be>
Victor Alekhin wrote:
>Is it possible to write a perl script that
>will make something like:
>
> mov al,ByteData
> xor al,255
> mov cx,8
> @1: rcl al,1
> rcr ah,1
> loop @1
> mov ByteData,ah
What are you trying to do, bit-reverse each byte, while inverting each
bit as well?
If you want efficiency, construct a conversion table. Use that in
substitution.
# Construct (once):
my %convert;
for my $byte (0 .. 255) {
my $orig = $byte;
my $reversed = 0;
for my $i (1 .. 8) {
$reversed <<= 1;
$reversed |= $byte & 1;
$byte >>= 1;
}
$convert{chr($orig)} = chr(0xFF & ~$reversed);
}
# Now use it:
$_ = "Hello, world!\n";
s/([\000-\377])/$convert{$1}/g;
print;
Bart.
------------------------------
Date: 13 Aug 1999 10:36:50 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Compare Two FILES
Message-Id: <37b449a2@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, "Romiko" <rvdd@iafrica.com> writes:
:I have been trying to write a script that compares two similar files and
:updates the changes , I have been trying for two days and cannot get it
:right.
Learn about the diff and patch, and maybe the cmp, commands.
--tom
--
"No problem is so formidable that you can't walk away from it."
--C. Schulz
------------------------------
Date: Fri, 13 Aug 1999 11:15:19 -0400
From: Uriel Wittenberg <urielw@tiac.net>
To: info@www.perl.com
Subject: HARASSMENT -- Monthly Autoemail
Message-Id: <37B43687.B0525875@tiac.net>
This comp.infosystems.www.authoring.html participant appears to have
opted to openly harass me -- by a monthly autoemail of his message --
in order to make me conform to his idea of correct style in posting.
Regardless of anyone's position on posting style, I would hope just
about everyone understands the vindictive and antisocial nature of
such behavior.
-------- Original Message --------
Received: from mx1.tiac.net (mx1.tiac.net [199.0.65.251]) by
maildeliver0.tiac.net (8.8.8/8.8) with ESMTP id LAA05648 for
<urielw@tiac.net>; Wed, 11 Aug 1999 11:18:47 -0400 (EDT)
Received: from jhereg.perl.com (tchrist@perl.com [199.45.135.9]) by
mx1.tiac.net (8.8.8/8.6.9) with ESMTP id LAA10457 for
<urielw@tiac.net>; Wed, 11 Aug 1999 11:18:43 -0400 (EDT)
Received: (from tchrist@localhost)by jhereg.perl.com (8.9.0/8.9.0) id
JAA25119;Wed, 11 Aug 1999 09:16:45 -0600
Date: Wed, 11 Aug 1999 09:16:45 -0600
From: Tom Christiansen <tchrist@jhereg.perl.com>
Message-Id: <199908111516.JAA25119@jhereg.perl.com>
To: urielw@tiac.net
Precedence: junk
X-Mailer: Perl AutoFAQ (stardate 1.001, mark B4B20)
Subject: Your quoting strategy and the Jeopardy game (was Re:
Documenting character encoding -- comments/corrections?)
X-Mozilla-Status: 9001
X-Mozilla-Status2: 00000000
X-UIDL: 2bda1f763114bc938f8f99cba2027441
[The following is a manually-generated but purely generic email
message from the Perl AutoFAQ program; you should not receive
more than one copy of this particular posting per 30
days so long as you continue to post under the name
urielw@tiac.net.]
EXECUTIVE SUMMARY:
To send better messages, please trim and summarize what you're
replying to, and integrate your quoted text with the body of your
message. Don't just put everything at the end. This isn't
Jeopardy.
People expect question-and-answer, not answer-and-question
responses.
LONG STORY:
Wouldn't you like to make your messages easier for others to read and
understand? If so, I have some news posting tips for you. If not,
just ignore this. (Of course, if you don't want your messages
easier to read and understand, it's not clear why to bother to
send them in the first place. :-) I'm going to take a bit of
time to explain this, because newcomers to Usenet often lack the
cultural background were I to send a superbrief message.
Here's the issue: you appear to have quoted the entire message to
which
you were replying. Worst of all, you have done so by merely appending
the complete message at the bottom. Folks are used to reading the
original material first, then the follow-up. That's why it's called a
"follow-up", you know. :-)
If all you want to do is forward a copy of the message, that's one
thing,
but here you seem to have just blindly pasted the complete old message
at
the end without providing any content. This is neither a proper
public
followup nor even a decent private reply. Here's why.
First of all, this is massive overkill -- you're supposed to trim your
quoted text to only what you're replying to. Otherwise you'll
probably
violate the netiquette target quoting percentage of 50%. See below.
This isn't really an issue of space (I know that a few bytes here and
there mean less today than 20 years go), so much as it is of
integrating
your comments with the old material for continuity.
Second, putting everything at the bottom does little good. It doesn't
provide the proper context. It's far too late. When you reply to
someone's content, the reason you quote the previous message is so
that
you can provide some degree of contextual continuity. The best way to
do this is to interleave what you're quoting with your responses to
that
particular piece. That means that you should provide a quoted
portion,
then address what the points therein, then another quoted section,
etc.
For example, here's how followup replies *should* look if you'd
like them to be more effective.
> Joe said we should eat noodles.
But I don't like noodles. They are a pain to prepare -- remember
that what started this thread was how to cook using only a
microwave,
not real cooking -- and they provide you with very little
sustenance
in the long run. It's like eating cardboard, nutritionally
speaking.
> He also suggests adding anchovies.
What is this fish fetish? Not all of us like the little minnows
with the lingering briny taste swimming around our mouths for the
next few hours or days. Can you imagine this on a date? Iccccch!
Notice how in the text above, alternate quoted passages are
interleaved
with new response text. Notice also that the new text far exceeds the
old text. This is the way it should be.
If you are receiving this message in response to a news posting,
please
understand that all modern newsreaders provide a mechanism to fetch
the parent article, so it is seldom necessary to quote the whole
thing.
Sometimes even mail readers provide this, depending on the mail
headers
and the list archival mechanism on your own system.
Here's a section from the essential netiquette guide, "A Primer
on How to Work With the Usenet Community", which is available in
news.announce.newusers. Perhaps your service provider neglected to
point
you at this newsgroup before you got swallowed up by all of Usenet.
It's not only a good read; it's critical to understanding the culture
you're now moving in.
Summarize What You are Following Up.
When you are following up someone's article, please summarize the
parts of the article to which you are responding. This allows
readers
to appreciate your comments rather than trying to remember what the
original article said. It is also possible for your response to get
to some sites before the original article.
Summarization is best done by including appropriate quotes from
the original article. Do not include the entire article since it
will irritate the people who have already seen it. Even if you are
responding to the entire article, summarize only the major points
you
are discussing.
I've already given a good example of how you should be quoting
followup
responses, and told you why this is a much better approach then what
you've done. Now, by way of demonstration, I'll show you the bad way.
At the end of this message, I include a forwarding of your complete
original, unaltered save for its quoted material. Please note how
completely useless this is, because at no point in the real message do
I pull in summarized portions of your original. In fact, I'm not even
using the data in your message. See how clumsy and unneeded this is?
It's very annoying, too.
It's even more annoying when people needlessly quote the original's
automatic trailing matter, like signatures, adverts, or disclaimers.
Please don't do that.
I'm honestly not trying to annoy you! I'm just trying to give tips
about what works well in electronic messages, and what doesn't. This
used to be standard fare before one got a Usenet account, but now
something seems to be lost.
If you can think of any way to make this message more helpful, please
let me know. I apologize in advance if this message comes off
sounding
unkind to you; it wasn't meant to be. I'm honestly just trying to
help
to make the Net a better place for all of us.
PS: here's the message I'm talking about
>Message-ID: <37AF0C2E.9E334DF5@tiac.net>
>From: Uriel Wittenberg <urielw@tiac.net>
>X-Mailer: Mozilla 4.61 [en] (Win95; U)
>X-Accept-Language: en
>MIME-Version: 1.0
>Newsgroups: comp.infosystems.www.authoring.html
>Subject: Re: Documenting character encoding -- comments/corrections?
>References: <37A7608D.4873244C@tiac.net>
<Pine.HPP.3.95a.990804004643.16621A-100000@hpplus03.cern.ch>
<37AB0220.10809FFB@tiac.net> <7of4o4$lv8@abyss.West.Sun.COM>
<37AB9FD9.AC9DF3A1@tiac.net>
<Pine.HPP.3.95a.990807150850.19738A-100000@hpplus03.cern.ch>
<37AD9540.5D34C086@tiac.net>
<Pine.HPP.3.95a.990808164954.14285E-100000@hpplus03.cern.ch>
<37AE0969.CD4A94D2@tiac.net>
<Pine.HPP.3.95a.990809015918.2140A-100000@hpplus03.cern.ch>
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>Lines: 110
>Date: Mon, 09 Aug 1999 17:13:26 GMT
>NNTP-Posting-Host: 154.11.93.212
>NNTP-Posting-Date: Mon, 09 Aug 1999 13:13:26 EDT
>Path:
cs.colorado.edu!csnews!nntp.primenet.com!nntp.gctr.net!howland.erols.net!peerfeed.news.psi.net!psinr!interramp!not-for-mail
>Xref: csnews.cs.colorado.edu
comp.infosystems.www.authoring.html:280400
>
>Alan,
>
>Try to focus:
>
>- How exactly have I "mixed up two issues"? Quote me, and be
precise.
>
>- I had asked about encodings "specifiable in HTML 4." You
responded, "t<SNIP>
+>here is no finite
>list of codings that are "allowed by HTML" in any formal sense."
Again, <SNIP>
+>I ask you how you
>reconcile this with the passage I quoted from
>http://www.w3.org/TR/REC-html40/charset.html#h-5.2 .
>
>Your points about browser support are not relevant to this question.
>
>
>"Alan J. Flavell" wrote:
>
>> On Sun, 8 Aug 1999, Uriel Wittenberg wrote:
>>
>> > > I mean "one of the encodings of unicode that the browser
supports".
>> >
>> > So you're saying: "Netscape fails to render &#bignumber; unless
the
>> > document's specified charset is one that it supports. 8859-1 is
not
>> > among these. UTF-7 and 8 appear to be."
>>
>> Do I? I've tried hard to make it very clear, as I say on my web
pages.
>> I shall have to take advice on whether I have succeeded.
>>
>> Netscape "supports" quite a number of 8-bit codings, but in none
of them
>> does it, in general, support &#bignumber; representations, aside
from a
>> small number of exceptions (which I suspect turn out to be those
>> displayable characters that are in Windoes-125x encodings which
are not
>> in iso-8859-* encodings: things like em-dash, "clever" quotes, TM
and
>> that sort of thing). So it supports those 8-bit codings well
enough as
>> to stagger along with English plus one non-Latin-1 repertoire;
what it
>> fails to do is to allow, say, French and Cyrillic to be mixed, and
so
>> on. Unless one uses one of th e unicode encodings, or at least
pretends
>> to do so by sending us-ascii and advertising it as utf-8 (which is
true,
>> albeit a kludge).
>>
>> > Really? Can you provide a <bignumber> example? If Netscape fails
to <SNIP>
+>render it
>> > properly in 8859-1 this should be pretty easy to verify.
>>
>> Of course. You can easily reproduce the tests; feel free to do
so.
>>
>> > > That was the whole _point_ of the
>> > > "conservative recommendation". I had hoped to have made that
clear.
>> >
>> > Frankly, it's really not.
>>
>> Again, I feel I have to take advice on that. You seem to be the
first
>> to report that these pages are incomprehensible in that respect.
I
>> invited you to put up a blow by blow critique of the page(s), and
that
>> offer is still open. This is no problem to me: I do not construe
>> criticism of the content in any kind of personal fashion, but I
find it
>> hard to cope with pseudo-polite answers that beat about the bush
and
>> won't address the issues directly.
>>
>> > You had remarked, "there's more than one coding of Unicode." I
didn't
>> > know what that meant or whether it bore on the discussion. I
asked
>> > what the remark meant? From your answer, it appears my guess
above as
>> > to the meaning was correct.
>>
>> If you like, but your way of expressing the situation was
non-standard,
>> hence the confusion.
>>
>> > I know about "repertoire" and avoided it in my text because the
conc<SNIP>
+>ept seems
>> > superfluous. How have I mixed up two issues?
>>
>> I find the concept of "repertoire" a useful one. Certainly one
should
>> distinguish between the concepts of "character set" and "character
>> encoding scheme" (as I recall, Czyborra's pages also stress this).
>>
>> It's a three-step process, really.
>>
>> - select your character repertoire
>> - assgn the characters to small(-ish) integer numbers ("character
set"
>> in the modern sense - not "charset" in the mime attribute sense)
>> - decide how to encode those numbers for transmission ("character
>> encoding scheme" in the modern terminology, "charset" in the mime
>> attribute terminology).
>>
>> > > In your second question; there is no finite list of codings
that are
>> > > "allowed by HTML" in any formal sense.
>> >
>> > http://www.w3.org/TR/REC-html40/charset.html#h-5.2 says:
>> >
>> > "protocol headers, attributes, and parameters referring to
character<SNIP>
+> encodings share
>> > the same name -- "charset" -- and use the same values from the
[IANA<SNIP>
+>] registry (see
>> > [CHARSETS] for a complete list)."
>> >
>> > To me this implies there is a standard set of encodings.
>>
>> If you like; but I assure you that you'll find a considerable lack
of
>> client software that will support _all_ of the encodings that are
>> registered at IANA. The HTML 4.0 standard does not even _require_
a
>> client agent to support iso-8859-1; I don't recall it forbidding
support
>> for non-IANA-registered "charset" values - it only calls on
information
>> providers to use a registered value.
>>
>> In fact, probably the statistically most widely de facto coding
used, at
>> least in our geographic regions, on the WWW, was _not_ registered
at
>> IANA, namely Windows-1252. I mention this merely as a fact,
without
>> offering any value judgement. Microsoft stated their intention of
>> registering it, but I've not yet seen this registration appear,
although
>> all the other values of Windows-125* seem to be there, weird as
that may
>> seem.
>>
>> Are we converging? I'm a bit concerned that no-one else seems to
have
>> joined this discussion, so it's proceeding in a bit of a vacuum.
>
--tom
--
Tom Christiansen Perl Consultant, Gamer, Hiker
tchrist@mox.perl.com
*** 16 years hanging out on Usenet ***
------------------------------
Date: 13 Aug 1999 16:30:19 GMT
From: jeromeo@atrieva.com (Jerome O'Neil)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <7p1h6r$aen$1@brokaw.wa.com>
In article <37B43687.B0525875@tiac.net>,
Uriel Wittenberg <urielw@tiac.net> writes:
> This comp.infosystems.www.authoring.html participant appears to have
> opted to openly harass me...
For excessive whining: (thats tough to do on c.l.p.m)
<* plonk *>
------------------------------
Date: Fri, 13 Aug 1999 12:16:48 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Help with CGI and perl
Message-Id: <linberg-1308991216480001@ltl1.literacy.upenn.edu>
In article <7p1a4l$7j8$1@oak.prod.itd.earthlink.net>, "David C"
<dcohny@earthlink.net> wrote:
> I will include my
> source.
If you would just paste the relevant code and a description of the problem
into your post, rather than attach a UUEncoded document (generally
verboten in non-binaries groups), you'll get a much higher rate of
response. Few people will have the time and interest to download and
decode your attachment, but if they can quickly glance over it in your
post, they might be more disposed to help.
--
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
Be kind. Remember, everyone you meet is fighting a hard battle.
print 'Just Another Perl ' . $perl_hierarchy[(USER+EXPERT)/2];
------------------------------
Date: Fri, 13 Aug 1999 11:56:41 -0400
From: "Jack Alexander" <Jack.Alexander@digital.com>
Subject: Re: Looking for a solution to the problem localtime and the century mark.
Message-Id: <7p1e84$kda$1@nntpd.lkg.dec.com>
I'm always surprise by the manner which people are treated in this
newsgroup; just a little too brittle. Oh well, I suppose that's what happens
when you don't talk to real people face to face very often.
Anyway, I found my answer; I just don't like it. It it hard for me to
understand that the problem hasn't been solved, but just pushed around the
corner. Adding 1900 to the year value from local time seems to me to be a
major hack. That is the first official one I personally have come across
using Perl.
Jack Alexander wrote in message <7ouof5$51u$1@nntpd.lkg.dec.com>...
>Hi all,
> I use Perl 5.0 42 on Windows NT and UNIX. I'm looking for a solution to
>the problem of localtime only returning a year value (99) and not a century
>value (19 -or- 20).
>
>Can anyone help?
>
>thanks,
>--
>Jack Alexander
>jack.alexander@compaq.com
>COMPAQ Computer Corporation
>UNIX/NT Software Development Environments
>110 Spitbrook Rd. ZKO2-3/Q08
>Nashua , NH 03062, USA
>(603) 884.2459
>
>
>
------------------------------
Date: Fri, 13 Aug 1999 10:40:11 -0400
From: "Jack Alexander" <Jack.Alexander@digital.com>
Subject: Re: Looking for a solution to the problem localtime and the century mark.
Message-Id: <7p19of$a8n$1@nntpd.lkg.dec.com>
Please clarify:
<extracted from "Programming Perl 2nd Edition">
localtime
localtime EXPR
.........
, and the year has had 1,900 subtracted from it.
.........
Larry Rosler wrote in message ...
>In article <7ouof5$51u$1@nntpd.lkg.dec.com> on Thu, 12 Aug 1999 11:32:49
>-0400, Jack Alexander <Jack.Alexander@digital.com> says...
>> I use Perl 5.0 42 on Windows NT and UNIX. I'm looking for a solution
to
>> the problem of localtime only returning a year value (99) and not a
century
>> value (19 -or- 20).
>
>The first place I would look for a solution is in the documentation for
>localtime. Have you done that? If so, what about it needs
>clarification?
>
>--
>(Just Another Larry) Rosler
>Hewlett-Packard Laboratories
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com
------------------------------
Date: Fri, 13 Aug 1999 18:55:45 +0200
From: Thomas Schmickl <schmickl@magnet.at>
Subject: Re: Moving a Perlscript from NT to LINUX
Message-Id: <37B44E11.B1790AE2@magnet.at>
"Alan J. Flavell" schrieb:
> OI use PFE (programmer's file editor) on Win32 platforms; it can
> save files in "unix" format. In fact, courtesy of Samba, I can
> save the results directly to unix. YMMV.
Thanks, using an editor that can save both fileformats sounds ver good to me !
ciao, thomas.
------------------------------
Date: Fri, 13 Aug 1999 16:07:29 GMT
From: geoff@access1.net (Geoff Joy)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <37b735ea.109140734@news.access1.net>
On 12 Aug 1999 17:03:47 GMT, Mike South <msouth@shodor.org> wrote:
>My advice to others who have problems with the docs, the way
>questions are answered, or the language of regular expressions
>is that, before you criticize the people that are giving this
>to you freely, you _attempt_, just _once_, _attempt_ to
>write something better, answer a few questions yourself (but
>make sure you point people to the FAQs, too!), or, better
>still, create NPPERLWCOSDSNEAIWM and publish it so we can
>point people to that instead.
>
If they have the time to read a post and compose a reply to it, the
reply can be courteous and directly answer the question, either by
pointing directly at the pertinent section of the FAQ or by a simple
example, or else IGNORE the question. Time is time, it's a complete
waste of everyone's time to read a lame post and an even more lame
snide post saying, "that's so lame, don't waste my time".
I have been lurking this group for over two months. I have read,
enjoyed and gained from the published Perl books. I have been
programming Perl for over 6 months. I have observed these modes of
behavior on this group.
1. The sneering cynical put-down that doesn't answer the question.
(i.e., DWMT, TISL, PYDN, RTFAQN) (Don't Waste My Time, That is so
Lame, Pay Your Dues Newbie)
2. The self-absorbed expert, preoccupied with trying to impress
himself and others with his knowledge of esoteric, obscure and
trivial snippets of code that have no other use.
3. Posts, in reply to questions, that deliberately mis-understand the
question in order to make fun of the poster.
4. Posts from those who are obviously so knowledgable and experienced
in Perl, and who have seen and done everything there is to see and
do in this group that they need to unsubscribe comp.lang.perl.misc
and go directly to alt.god.ultimate.answers and let Him know the
real Truth.
5. A minority of sincere, succinct and correct answers.
If you have the time to lurk and read this group, and if you have the
time to post a response, then let it convey good information about
Perl, not about your sense of humor(or lack thereof), not about how
smart you are, not about how dumb the questioner is. If your time is
so precious, then don't read the group, don't post glib rejoinders, go
back into your office and write your code, make a jillion dollars and
retire, secure in the knowledge that you have made the world a better
place.
------------------------------
Date: Fri, 13 Aug 1999 16:40:49 GMT
From: id-est@home.com (Id Est)
Subject: Re: Nastiness contrary to the spirit of perl?
Message-Id: <slrn7r8ii8.4hk.id-est@erato.bigredrockeater.com>
In article <37b735ea.109140734@news.access1.net>, Geoff Joy wrote:
<snipped>
well said, my sentiments exactly.
------------------------------
Date: Fri, 13 Aug 1999 11:35:16 -0500
From: Mike <kangas@anlon.com>
Subject: Re: Newbie question
Message-Id: <37B44944.62DE28F4@anlon.com>
try...
open(IN, "filename");
while(<IN>) {
$line = $_; # if you wish
chomp $line;
# do some stuff
# and yet more stuff
}
Damm Dashing wrote:
> Dear Folks,
>
> I apologize if this question inadvertantly takes up anyone's time.
>
> I have a while loop that goes:
>
> while ($line = <IN>) {
>
> chop $line;
>
> #do some processing
> #print the line
> } # while
>
> where IN is the filehandle for an open flatfile. The problem I'm having
> is that the flatfile looks like (note: the line numbers are for clarity
> purposes only, they don't appear in the actual file):
>
> 1. blah blah blah blah blah
> 2.
> 3. ***********
> 4.
> 5. more text in here, ya dig it?
> 6. &c...
>
> And the output from the program only returns the first line. The
> processing done on the subsequent lines does not remove them, ie. the
> script should return multiple lines (it did before I changed my loop
> construct to while($line=<IN>)).
>
> I'm wondering what I'm doing wrong here...
>
> Please reply to my e-mail address, in addition to any other places.
> Thanks in advance!
>
> Greg.
--
Michael Kangas
Anlon Systems, Inc.
kangas@anlon.com
------------------------------
Date: 13 Aug 1999 12:08:09 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Possible Perl Bug or Just Me
Message-Id: <x7aerv64uu.fsf@home.sysarch.com>
>>>>> "sh" == <stirling@banet.net> writes:
sh> sh.pl (take 1)(the ineffective script):
sh> #!/usr/bin/perl -w
sh> use strict;
sh> $orig='sample.txt';
sh> chmod (0700,$orig);
sh> sh1.pl (take 2)(the effective script):
sh> #!/usr/bin/perl -w
sh> use strict;
sh> $orig="sample.txt";
sh> chmod (0700,$orig);
sh> -----------------------------------------------
you don't show the file modes before or after your scripts run so how
can we believe your claims. that is not how you demonstrate something,
you have to show all the pertinent data.
and perl will not interpret those 2 scripts differently. you seem to
have a major bug up your bonnet on this. i will wager a very large sum
of quatlos that you are very mistake in interpreting the results of your
scripts.
have you tried this:
$orig1 = 'sample.txt' ;
$orig2 = "sample.txt" ;
print "my perl is broken!\n" if $orig1 ne $orig2 ;
on top of all that, they won't even compile since you use strict, but
don't declare $orig. so you have another mistake in your post. please be
more careful what you post here and claim.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: 13 Aug 1999 16:32:43 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Possible Perl Bug or Just Me
Message-Id: <slrn7r8i5b.af2.M.Ray@carlova.ulcc.ac.uk>
On Fri, 13 Aug 1999 12:00:25 -0400, stirling@banet.net <stirling@banet.net>
wrote:
>In the following two scripts the only change is in the single and double
>quotes, however, the one with single quotes doesn't work and the one with
>double quotes does. I have attached the output of perl -V for my host
>system. Please let me know if this is a perl bug or a bug on my system or
>my Perl code.
>
>sh.pl (take 1)(the ineffective script):
>#!/usr/bin/perl -w
>use strict;
>
>$orig='sample.txt';
>chmod (0700,$orig);
>---------------------------------------
>sh1.pl (take 2)(the effective script):
>#!/usr/bin/perl -w
>use strict;
>
>$orig="sample.txt";
>chmod (0700,$orig);
>-----------------------------------------------
Neither of those will compile as they stand, and you don't say *how*
they don't work. Try this:
#!/usr/bin/perl -w
use strict;
my $orig='sample.txt';
chmod (0700,$orig) or die "chmod failed: $!";
printf "0%o\n", (stat($orig))[2];
and the corresponding one with double quotes. chmod sample.txt to some
different permissions before the run, so that the change will be visible.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Fri, 13 Aug 1999 19:13:55 +0300
From: "Hendrik N6ulik" <hendrik@doora.ee>
Subject: Re: problem with ping() in perl
Message-Id: <7p1gk5$e8r13@kaie.va.ttu.ee>
Elaine -HFB- Ashton wrote in message <37B42F22.417148F1@chaos.wustl.edu>...
>Hendrik N6ulik wrote:
>>
>> The following code might be identify if other machine responds
>> over tcp/ip. But something is wrong because ping alwais
>> returns 0. Why? I have no idea. maybe somebody would help me?
>
>ping uses ICMP not TCP.
>
>e.
yes, this was good notice, it's okay now
thx,
hendrik
------------------------------
Date: Fri, 13 Aug 1999 16:39:51 +0000
From: Mark McCoy <mcking@cajunbro.com>
Subject: Re: Review for Algo. in Perl
Message-Id: <37B44A57.B7C611E2@cajunbro.com>
Anno Siegel wrote:
>
> Elaine -HFB- Ashton <elaine@chaos.wustl.edu> wrote in comp.lang.perl.misc:
> >Abigail wrote:
> >> *** ACHTUNG! ALLES LOOKENSPEEPERS! ***
> >
> >LOL! Ich spewen mein kaffee while lesen zis.
> >
> >That's a keeper. :)
>
> M333 T000!!!1
>
> Anno
wtf?
--
Mark McCoy -- Cajun Brothers Technology, llc
Proud to run Linux since February 1996
This message posted from snowdog, a 100% MS-free machine.
The views in this message do not necessarily reflect the views of my employer
------------------------------
Date: Fri, 13 Aug 1999 12:24:18 -0400
From: Marshall Dudley <mdudley@execonn.com>
Subject: saving a hash
Message-Id: <37B446B2.136F5A10@execonn.com>
I have an application where I am doing a database type operation with a
flat file. The file has grown to over 1,000 entries, and now it is
taking to long to do a linear search for the "key".
What I need to do is change it over to a hash. But if I try to print a
hash to a file, then retreive it, I end up with garbage. If I write it
as arrays (like I am presently doing), then it takes too long to
recreate the hash each time I access the file.
Does anyone know how I can read and write a hash from the hard drive so
I don't encounter the overhead of having to recreate the hash on each
invocation?
Thanks,
Marshall
------------------------------
Date: Fri, 13 Aug 1999 18:06:53 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Sending mail to "QuestionExchange"
Message-Id: <Pine.HPP.3.95a.990813180354.5423C-100000@hpplus03.cern.ch>
On 13 Aug 1999, Anno Siegel wrote:
[..]
> They had 300+ postings in four days (8-12 Aug).
>
> Well, I guess they won't last long. The nature of their fraud will
> soon be known all over usenet.
Well, Deja's only record of them being mentioned on
news.admin.net-abuse.usenet are some entries in the net-abuse statistics
for exceeding the BI.
Is anyone feeling robust enough to write up these observations and
put their heads above the net-abuse group parapet?
------------------------------
Date: 13 Aug 1999 17:02:51 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sending mail to "QuestionExchange"
Message-Id: <7p1j3r$sqf$1@lublin.zrz.tu-berlin.de>
Alan J. Flavell <flavell@mail.cern.ch> wrote in comp.lang.perl.misc:
>On 13 Aug 1999, Anno Siegel wrote:
>
>[..]
>> They had 300+ postings in four days (8-12 Aug).
>>
>> Well, I guess they won't last long. The nature of their fraud will
>> soon be known all over usenet.
>
>Well, Deja's only record of them being mentioned on
>news.admin.net-abuse.usenet are some entries in the net-abuse statistics
>for exceeding the BI.
Yes, I know. That doesn't make it spam, and unfortunately it isn't.
I had a brief email exchange with the guy who runs the stats.
I'm afraid at the moment we must deal with them in each newsgroup.
I notice they haven't posted here today, for my value of today. But
then, they're probably only overhauling their bot.
>Is anyone feeling robust enough to write up these observations and
>put their heads above the net-abuse group parapet?
Oh dear. Is there any useful dialog going on on n.a.n-a.usenet?
A quick look shows only hysterical flamewars, but that are of course
the big threads.
Anno
------------------------------
Date: Fri, 13 Aug 1999 15:45:22 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Stopping output
Message-Id: <7p1eml$kr3$1@news.mch.sbs.de>
In article <37B1B39D.B17A6311@home.com>, Joan Richards <richj@home.com> wrote:
>> >RTFFAQ.
>>
>> Which one are you referring to ?
>
>Michael - did you ever receive a response from abigail on this one?
Nope.
Michel.
------------------------------
Date: Fri, 13 Aug 1999 16:26:53 GMT
From: jsilve1@my-deja.com
Subject: Strange trouble with a STRAY CURLY BRACE "}"
Message-Id: <7p1h04$44a$1@nnrp1.deja.com>
I have this script, it may or may not matter what it does, I don't
know, but I'll sum up as follows:
script basically just prints stuff out to the screen. there are a
couple of subroutines to print out header and footer info.
when testing the script, i get a syntax error "missing right bracket
at script_name line..." basically saying that i need a closing "}"
at the end. no biggee, right? just put a close brace on (which i did)
and it should work fine, right? Well it did.
See, the thing is that there is no matching open curly brace for this
close curly brace!!
I use the Vi editor. Vi has a key command (%) which shows matching
braces, parens, or brackets by jumping back and forth between them.
but on this brace it just beeps, indicating a stray curly brace!
WTF?
any comments, ideas, or suggestions?
thank you.
-Jeff Silverman
jeff@jhmi.edu
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 13 Aug 1999 16:37:28 +0000
From: Mark McCoy <mcking@cajunbro.com>
Subject: Re: Stripping quotes only from HTML tags
Message-Id: <37B449C8.E2F4785D@cajunbro.com>
Warren Bell wrote:
>
> Warren Bell writes ..
> >>I have a messageboard script that I want to strip the quotes out of
> >>anything within HTML tags that is entered in the text area. If a quote>is entered as text like: try the command "foo -a" it woulden't get
> >>stripped. But anything in between < and > gets the quotes stripped from>it.
> >
> >>Is there a way to do this with a simple substitution like:
> >
> >>$message =~ s/?/?\g;
>
> >well you're a real "roll over and scratch my tummy please" guy aren't >you .. one day all that "read the documentation"
> >advice will slip through the cracks into your brain
>
> And your the type of guy who spends his time on newsgroups waiting for
> opertunities to try and talk trash to people instead of helping out. I
> guess that makes you feel important or somthing.
>
> For your information, maybe I don't have time to learn Perl. Maybe I'm
> busy with other things and thought I could come into a newsgroup to get
> a quick answer. I'm sorry, I didnt know there were prerequisites for
> posting. When someone comes to an HTML newsgroup I don't tell them to
> buy a book and figure it out for themselves. It's called help, fool.
>
>
> >*plonk*
> Sorry again, I dont understand nerd lingo.
> --
> jason - elephant@squirrelgroup.com -
> --
> ####### Remove ERASE to reply #######
1. You should have asked a question that required less than a few minutes to
answer.
2. He should have let you know IN A NICER TONE that this needs a more
complicated answer than you expected.
You should read "man perlre" (the perl regular expression man page). After
reading this, you would probably figure out that this a complex problem that
requires more than a one-liner, and asked "Is there a perl module somewhere that
lets me parse HTML?".
I'll admit that Tom needs to chill, though...
T
--
Mark McCoy -- Cajun Brothers Technology, llc
Proud to run Linux since February 1996
This message posted from snowdog, a 100% MS-free machine.
The views in this message do not necessarily reflect the views of my employer
------------------------------
Date: Fri, 13 Aug 1999 12:31:26 -0400
From: Robert Watkins <rwatkins@springer-ny.com>
Subject: Re: tail equiv. using Perl on Win32 ?
Message-Id: <37B4485E.87B8EABA@springer-ny.com>
Jon Peterson wrote:
>
> Perl's seek function will let you jump to a point in the file. Sadly, it will
> only take you to a specified number of bytes into the file, rather than lines.
>
Thanks for the tip; sounds interesting. Although as I think about how
best to impliment this (check the size of the file, seek to some point
shortly before EOF, look for a newline, grab everything up to the last
newline, blah, blah, blah ...) it's almost as if I'm writing the thing
in C!
-- RW
------------------------------
Date: 13 Aug 1999 18:35:09 +0200
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: tail equiv. using Perl on Win32 ?
Message-Id: <7p1hft$sii$1@pharmnl.ohout.pharmapartners.nl>
In article <kmXs3.87$u07.761@news.colt.net>,
Jon Peterson <jpeterson@office.colt.net> wrote:
>
>Still, if you can assume a reasonable maximum line length in the log file, you
>can position the file pointer at, say, approximately 20 lines from the end of
>the file (to be on the safe side). Then you need only read in twenty lines
>worth of data to determine the penultimate line.
>
>This sounds rather ugly, but I can't think of a better way off hand.
>
Ugly or not. That is excatly how tail does it. It lseeks to about 1000 bytes
from the end and goes from there.
Villy
------------------------------
Date: Fri, 13 Aug 1999 13:00:51 -0400
From: Robert Watkins <rwatkins@springer-ny.com>
Subject: Re: tail equiv. using Perl on Win32 ?
Message-Id: <37B44F43.9FEFE005@springer-ny.com>
Jon Peterson wrote:
>
> Perl's seek function will let you jump to a point in the file. Sadly, it will
> only take you to a specified number of bytes into the file, rather than lines.
>
Got it! The following gives me the last 10 lines or so, in about half
the time of the tail/awk combination. Thanks again.
open(LOGFILE, "$logfile") or die "Can't open $logfile for reading:
$!\n";
seek LOGFILE, -50000, 2;
while(<LOGFILE>) {
if (/^(\d\d\d\d-\d\d-\d\d)/) {
print $1 . "\n";
}
}
close(LOGFILE);
------------------------------
Date: Fri, 13 Aug 1999 09:21:44 -0700
From: Miles Egan <milese@pacbell.net>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B44618.ED01B54@pacbell.net>
> "Perl is the Cliff's Notes of Unix" - I think should be "Perl is the Cliff's
> Notes of C/C++". At least that is how I generally use it. It amazes me that
> after 50 years of computer language research, we still have C/C++ programmers
> reimplementing dynamically allocated lists and hashes in hundreds of different
> ways, modifying them each time because they don't quite fit the situation,
> causing all sorts of memory leaks and wasted effort. String handling, pattern
> matching and other features of Perl are all bonuses, because while I could
> implement a specialized pattern matching algorithm for a particular program, why
> should I have to? I am here to solve problems, move data around, grind it up,
> and spit it out -- not waste time fiddling with linked lists and malloc, etc...
Of course, now that the STL is a part of standard C++, nobody has much
of an excuse to do this in C++.
miles
------------------------------
Date: Fri, 13 Aug 1999 09:27:17 -0700
From: Miles Egan <milese@pacbell.net>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B44765.E194F3CD@pacbell.net>
> While at university we used a somewhat obscure functional language
> called 'ml' which was originally designed for theorem proving. If Perl
> advocates think that Python is strict, they would have difficulty
> believing that anyone would willingly program in ML! Every statement
The curious might want to have a look at OCaml. http://caml.inria.fr.
It's a dialect of ML that's freely available for mac, windows and unix
that's also very fast (much faster than perl or python in general). It
compiles to very fast bytecode or screamingly fast native code. It's
strict and allows a completely imperative style, so it's much easier for
C or Perl or Python programmers to grasp than Haskell or Clean. It's
design philosphy is quite different from Perl's or Python's, but it's
useful for many of the same tasks. Language collectors owe it to
themselves to take a look.
miles
------------------------------
Date: Fri, 13 Aug 1999 17:33:00 +0100
From: Ian Clarke <I.Clarke@strs.co.uk>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B448BC.417309C0@strs.co.uk>
> Some of your statements were altogether too ludicrous to contemplate an
> earnest response.
Yet another (literally) unfounded statement! You must understand that
it is simply not sufficient (if you wish to be taken seriously) to
contradict what someone has said without some form of backup (and
personal insults do not constitute support for an argument). If you are
unwilling to follow this most basic guideline in a response to an email
or newsgroup post, then it is better you do not respond at all.
> You have all the trappings of the troll.
Let us clarify:
Jargon File (v4.0.0):
"""
troll troll /v.,n./ [From the Usenet group alt.folklore.urban] To utter
a
posting on Usenet designed to attract predictable responses or flames.
"""
As I have repeatedly stressed, my intention is not to attract flames.
My intention is to find out about the relative merits of Perl and Python
- according to the Jargon file, I am not trolling. My very first post
stated that I had looked quite extensively for a comparison between Perl
and Python, and had failed to find one. If the responses I was seeking
were predictable then why post on a subject where I couldn't find any
prior information?
If you look back through comments in this thread you were the first
to become rude and insulting, not me - if you look elsewhere in the
thread you will see that others have managed to participate in this
discussion without resort to childish insults, why can't you do the
same?
If the best answer you can provide to a reasonable question such as
"How does your language compare to xxx?" is "Go find out yourself"
(accompanied by copious insults) then I suggest you refrain from
responding to newsgroup posts, you do your fellow Perl advocates a
disservice.
> This is the wrong medium for the knowledge you ostensibly seek.
Quote from "The Perl Institute" web page:
"comp.lang.perl.misc is a newsgroup for general discussion of Perl"
So let me be clear on this. A newsgroup for general discussion of Perl
is the *wrong* place to ask a question about the merits and demerits of
Perl?! Where, prey tell, is the right place?!
> I have already spent more than six precious hours of my ever-shortening
> span upon you, completely gratis.
Forgive me if I lack sympathy. I didn't make you reply to my initial
posting. You could (and given the quality of your recent responses,
probably should) have ignored my post.
If your reply to this post will be "I want to end this discussion" then
don't bother replying, as I *will* respond to your comments if I find
them disagreeable.
Ian.
------------------------------
Date: Fri, 13 Aug 1999 16:50:20 GMT
From: Skip Montanaro <skip@mojam.com>
To: tchrist@mox.perl.com
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <7p1ic8$51h$1@nnrp1.deja.com>
Along the lines of DWIM, the following seems to me to be a DWIMish
shortcoming in Perl:
echo 'print "19" + "14.5";' | perl
33.5
Python recognizes that I explicitly fed it strings:
echo 'print "19" + "14.5";' | python
1914.5
I believe the knife can cut both ways.
--
Skip Montanaro (skip@mojam.com, 847-971-7098)
Mojam: "Uniting the World of Music" http://www.mojam.com/
Musi-Cal: http://www.musi-cal.com/
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 503
*************************************