[9345] in Perl-Users-Digest
Perl-Users Digest, Issue: 2940 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 22 23:08:58 1998
Date: Mon, 22 Jun 98 20:00:23 -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 Mon, 22 Jun 1998 Volume: 8 Number: 2940
Today's topics:
Re: after 5 hrs, the beginner beats the s/// (Bob Trieger)
Re: after 5 hrs, the beginner beats the s/// <*@qz.to>
Re: after 5 hrs, the beginner beats the s/// <rootbeer@teleport.com>
Re: after 5 hrs, the beginner beats the s/// (Ronald J Kimball)
Re: after 5 hrs, the beginner beats the s/// (Bob Trieger)
Re: Flames.... <rootbeer@teleport.com>
Re: Flames.... (Michael J Gebis)
Re: Flames.... <ljz@asfast.com>
Re: Flames.... <mike.schleif@aquila.com>
Re: Flames.... <mike.schleif@aquila.com>
Re: Flames.... birgitt@my-dejanews.com
Re: Flames.... (John Moreno)
Re: Flames.... (Ronald J Kimball)
Re: Flames.... (Ronald J Kimball)
Hash iteration (trying to avoid looping through the ent <tkent@pdq.net>
Re: More Complete Delete Example <rootbeer@teleport.com>
Re: More Complete Delete Example (Bob Trieger)
Re: Pat space doesn't change in nested whiles (Charles DeRykus)
Perl Position Papers due lisam@oreilly.com
Re: Sick things to do in foreach loops <mike.schleif@aquila.com>
syswrite behavior on Win32 (Michael Nielson)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Jun 1998 02:13:36 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <6mn340$ptt$1@ligarius.ultra.net>
"Brent Verner" <REPLY_TO_damonbrent@earthlink.net> wrote:
-> This is a multi-part message in MIME format.
->
-> ------=_NextPart_000_0044_01BD9E1F.9D5F86A0
-> Content-Type: text/plain;
-> charset="iso-8859-1"
-> Content-Transfer-Encoding: quoted-printable
DO NOT DO THIS!! Usenet is text based. I don't need no mime telling me it is
text. I know that already.
-> sorry for wasting the space and time, but i had to celebrate my victory =
-> over ONE silly line of code. i just spent about 5 hours trying to get =
-> ONE line of code to do what i needed it to. i needed to get rid of any =
-> \s characters at the beginning and end of a $line which needed \s =
-> chars in the middle ( the line was read from an html page that =
-> eventually is placed in a text box to be edited...just a broswer based =
-> web-page editor, but a more powerful one than is otherwise =
-> available...), so i tried about a million different s/// lines, but =
-> none would work on BOTH ends of the $line. i ended up with the =
-> following line and a bald spot on the side of my head:
->
-> $line =3D~ s/^\s+(?=3D\S*) | *\s*$//g;
$line =~ s/^\s*(.*)\s*$/$1/;
That is what you are looking for and if you checked the FAQs, you wouldn't
have wasted 5 hours.
>> snipped bazillion lines of HTML <<
Please don't do that either. HTML belongs on the web, not in my newsreader.
HTH
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
and let the jerk that answers know that his
toll free number was sent as spam. "
------------------------------
Date: 23 Jun 1998 02:33:23 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <eli$9806222227@qz.little-neck.ny.us>
In comp.lang.perl.misc, Brent Verner <REPLY_TO_damonbrent@earthlink.net> wrote:
> This is a multi-part message in MIME format.
Please don't do that.
> hmm...well i feel dummer now...
>
> $line =~ s/^\s* | *\s*$//g;
>
> does the same thing and looks nicer.
$line =~ s/^\s+|\s+$//g;
Why? Yours will take any whitespace at the start that ends with a plain
space and remove it. Mine removes any whitespace at the start without
that restriction. Yours will then remove zero or more spaces followed by
zero or more arbitrary whitespace at the end. Mine will remove one or
more whitespace at the end. Since removing zero instances of whitespace
is pretty harmless, the + vs. * here is not too significant.
This has, by the way, come up many times in this group. You probably could
have found the answer at Dejanews.
Elijah
------
writer of very complex s/// statements
------------------------------
Date: Tue, 23 Jun 1998 02:34:48 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <Pine.GSO.3.96.980622192926.3398U-100000@user2.teleport.com>
On Tue, 23 Jun 1998, Bob Trieger wrote:
> $line =~ s/^\s*(.*)\s*$/$1/;
Now, you know that that won't strip any trailing whitespace (except for
trailing newlines). Right? :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 22 Jun 1998 22:50:12 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <1db1qhy.1hkb5j71t540njN@bay1-172.quincy.ziplink.net>
[posted and mailed]
Brent Verner <REPLY_TO_damonbrent@earthlink.net> wrote:
> hmm...well i feel dummer now...
>
> $line =~ s/^\s* | *\s*$//g;
>
> does the same thing and looks nicer.
Well, this isn't going to make you feel any smarter, but... did you
think to check the FAQ?
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq4/How_do_I_str
ip_blank_space_from_.html
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 23 Jun 1998 02:40:01 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: after 5 hrs, the beginner beats the s///
Message-Id: <6mn4lj$kst$1@strato.ultra.net>
[ posted and mailed ]
Tom Phoenix <rootbeer@teleport.com> wrote:
-> On Tue, 23 Jun 1998, Bob Trieger wrote:
->
-> > $line =~ s/^\s*(.*)\s*$/$1/;
->
-> Now, you know that that won't strip any trailing whitespace (except for
-> trailing newlines). Right? :-)
Yes, I do. Was a typo. Thanks for pointing it out.
$line =~ s/^\s*(.*?)\s*$/$1/;
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
and let the jerk that answers know that his
toll free number was sent as spam. "
------------------------------
Date: Tue, 23 Jun 1998 01:57:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Flames....
Message-Id: <Pine.GSO.3.96.980622185608.3398Q-100000@user2.teleport.com>
On Tue, 23 Jun 1998 birgitt@my-dejanews.com wrote in response to a message
of mine:
> Getting all upset and outraged and starting a long discussion
> and analysis of the state of affairs doesn't help much either.
I'm not certain how to take this. Have I done anything that entitles you
to label me "upset and outraged"? Did I start "a long discussion and
analysis of the state of affairs"? Are you saying that your contributions
to this discussion are helping but mine aren't?
Please clarify.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 23 Jun 1998 01:58:51 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Flames....
Message-Id: <6mn24r$17l@mozo.cc.purdue.edu>
rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
}Chris Miller <apminc@cvn.net> wrote:
}> It seems that newbies are comparable to flies around here. You tolerate
}> them for awhile but you're annoyed to all hell by them. Lighten up a bit.
}> Don't respond if you don't want to be bothered.
}If your house is infested with flies, don't pay any attention to them.
}They'll go away. Really.
Tell them to read the FAQ.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 22 Jun 1998 22:02:09 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Flames....
Message-Id: <ltvhpsub8e.fsf@asfast.com>
rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
> Chris Miller <apminc@cvn.net> wrote:
>
> > It seems that newbies are comparable to flies around here. You tolerate
> > them for awhile but you're annoyed to all hell by them. Lighten up a bit.
> > Don't respond if you don't want to be bothered.
>
> If your house is infested with flies, don't pay any attention to them.
> They'll go away. Really.
Given that c.l.p.misc is a public, non-moderated newsgroup, I do not
believe that anyone has the right to say that it's *their* house. And
furthermore, given that the "newbies" who come here are human beings
like everyone else, I also take strong issue with the insulting
characterization of them as "flies".
It's true that c.l.p.misc has for quite a while been the de facto home
of a group of people who generally share certain views, preferences,
outlooks, abilities, and desires. It's also true that in recent
years, lots of people have come here who don't always share all these
views, preferences, outlooks, abilities, and desires.
It's understandable that those who have felt at home here for a long
time are disturbed by this influx of people who don't fit in with the
previously established patterns and conventions in c.l.p.misc. There
are several ways that the regulars here can deal with this issue.
Here are five of them that come to mind:
(1) ... use killfiles, the 'n', key, etc. In other words,
ignore it.
(2) ... accept that things have changed and give it no further
thought.
(3) ... politely and respectfully try to explain the established
patterns to the newcomers, and (still politely and
respectfully) try to persuade them to continue to adhere
to these conventions if they don't initially do that.
(4) ... treat the newcomers in an insulting and condescending
manner in an attempt to chase them away or "educate" them,
even going so far (for example) as to publicly equate them
with foul insects such as flies.
(5) ... start a moderated newsgroup which then *can*
justifiably be compared to a private home, and where
those who don't fit in can be easily excluded.
I consider numbers 1, 2, 3, and 5 to all be decent, mature ways of
dealing with this issue. Number 4 is, in my opinion, childish,
narrow-minded, and lazy.
I understand that it's hard to maintain ones composure over a long
period of time of having to deal with something that isn't to ones
liking. And of course, one could be readily forgiven for "losing it"
once in a while and temporarily falling into the kind of behavior
described in number 4. However, that doesn't make number 4 right.
It's something which I believe that people should apologize for, not
try to defend.
Most people here engage in the behaviors described in numbers 1, 2, 3,
and 5, and some go beyond even this and try to offer help to those who
come here with questions. In other words, most people here appear to
me to be decent and mature individuals. I'm thankful that it's only a
small (but vocal) minority who seem to habitually engage in the kind
of behavior outlined in number 4.
And I'm looking forward hopefully to the day when c.l.p.moderated
finally comes into existence. Then, those who want a Perl "home" on
usenet will finally have their wish, and they will be able to enjoy
the kind of forum that they've been trying to hammer c.l.p.misc into.
This will no doubt lower the levels of exasperation and frustration
that some of these regulars have been experiencing here of late, and
(I hope) with a corresponding rise in the levels of respect and
civility among all who continue to post to c.l.p.misc.
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: Tue, 23 Jun 1998 02:28:12 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: Flames....
Message-Id: <358F120A.8D355002@aquila.com>
This is by far the longest thread in several weeks. Is that
interesting? And some of you complain about wasted bandwidth . . .
Berating people and name calling never contribute value to any
situation.
Bottomline, if you do not want to help the beleaguered, do NOT respond
to their questions. If nobody answers, they will go away -- so much
more bandwidth for enlightening topics, such as this!
How does it go: "Give a man a fish and feed one; teach him to fish and
feed thousands . . . "
I also agree that code samples for these beleaguered are pointless until
they have digested the appropriate sections of the FAQ. The FAQ is so
rich in content, I am often amazed. Thank you all, again and again, for
scribbling down all of this. Can we lead people to the information;
but, let them make of it what they will?
Notwithstanding all of the egregious 'grep' thumping, it is all too easy
to miss the needle in the haystack. Even the most devout forget which
version of the FAQ has the most uptodate answer to particular
questions. Another thread herein suggests that all of us, gods and
novitiates alike, should be using 5.004_67 in order to do uptodate
FAQing.
>From my meager vantage point, I do not think that I, nor my clients, are
ready for 5.004_67 -- I'm waiting for God to get it right first . . .
Michael J Gebis wrote:
> }> The faq is big. The docset for perl is big. This is a good thing, but it
> }> is not without problems. It's hard to find stuff if you lack context.
> }> Dejanews is worse -- if you don't have some good keywords, you'll end up
> }> finding 200,000 seemingly random results.
>
> Answering "RTFAQ, look for XXXX" at least gives those who are truly
> confused a way to narrow the search space. The lazy probably still
> ignore it, but then again, maybe that's the point.
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Tue, 23 Jun 1998 02:34:55 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: Flames....
Message-Id: <358F139D.544203F3@aquila.com>
But (never start a sentence with 'but,') berating flies and calling them
names is more effective than hiring an exterminator . . . and loads more
fun!
Ronald J Kimball wrote:
>
> If your house is infested with flies, don't pay any attention to them.
> They'll go away. Really.
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Tue, 23 Jun 1998 02:31:32 GMT
From: birgitt@my-dejanews.com
Subject: Re: Flames....
Message-Id: <6mn425$ffe$1@nnrp1.dejanews.com>
In article <Pine.GSO.3.96.980620193203.20995L-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
>
> On 20 Jun 1998, Russ Allbery wrote:
>
> > Am I the only one who thinks that a periodic posting on how to find
> > things in Perl documentation would be a good thing?
>
> I doubt that such a posting would help - If someone can't figure out how
> to search text files on their own, they probably aren't smart enough to
> understand what they would find in the Perl docs if they did look. And if
> they simply _won't_ look, they'll never read or heed your posting.
That's true. I would agree.
But they would stop asking if they didn't get an answer and at the
same time are almost 'forced' to read these subject lines:
"WHY YOU DON'T GET AN ANSWER TO YOUR QUESTION"
"WE EXPECT YOU TO HELP YOURSELF AND READ THE DOCS"
Even if that would be posted daily it is much less noisy than personal
posts to straighten the FAQ poster out. You don't need to open
these automated posts, but other newbies need to open the
FAQ question (because they can't recognize a potential FAQ question
yet) and they need to open the personal response, which is just the
pointer to a doc or a flame.
By not answering a FAQ newbie question, but relying that the newbie
will 'get' why he didn't get an answer, when s/he sees and reads
"WHY YOU DON'T GET AN ANSWER TO YOUR QUESTIONS"
cuts the number of useless answers in half.
And a FAQ newbie who didn't get an answer *will* read it, because
he expected to get an answer and is most probably a bit disappointed
not to have gotten one.
>
> But don't let me stop you, if you want to make such a thing. Of course,
> you shouldn't restrict it to the Perl docs - Make it general enough to
> apply to any docs and FAQs, and cover searches on non-Unix machines as
> well as Unix machines. Good luck with it!
It sure is helpful, but honestly, I don't think it has much to do with
knowing how to "grep" or not, or if you know "how to search your file
system" or not, or how much you know about what is sitting where on
your unix box or how you get what you need to be placed where it belongs.
If someone needs and want to find out, he will, if he doesn't, it means
he didn't really need it, I believe.
At least I had the feeling that I could find everything, I could find
the pointers and the rest is reading top to bottom carefully.
You just have to do it, no shortcuts.
Birgitt Funk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 23 Jun 1998 02:45:12 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: Flames....
Message-Id: <1db1qeu.19xyflkfwtaz8N@roxboro0-010.dyn.interpath.net>
Michael J Gebis <gebis@albrecht.ecn.purdue.edu> wrote:
> phenix@interpath.com (John Moreno) writes:
>
> }But Tom snipped and didn't address what I consider a important part of
> }Gebis's message, namely:
>
> }> The faq is big. The docset for perl is big. This is a good thing, but it
> }> is not without problems. It's hard to find stuff if you lack context.
> }> Dejanews is worse -- if you don't have some good keywords, you'll end up
> }> finding 200,000 seemingly random results.
>
> }And this brings up a point which needs to be made - if you don't know
> }enough about what you want to do to figure out a range of keywords or
> }starting point to find what you are looking for, then you probably don't
> }need a answer because you don't know enough to have a valid question
> }(with a obvious exception for people who don't speak english very well).
>
> Without getting into the finer points, I still stand by my assertion:
>
> Answering "RTFAQ" does nobody any good. The lazy ignore it, the truly
> confused still have no context.
>
> Answering "RTFAQ, look for XXXX" at least gives those who are truly
> confused a way to narrow the search space. The lazy probably still
> ignore it, but then again, maybe that's the point.
There's no reason for you (or anybody else) to NOT say "look for XXXX",
but I don't think it's of a clear enough benefit that you should rag on
somebody else who just says RTFAQ (not that you did). Most of the
people asking these questions just don't WANT to read - if you've got a
spare hour or two you could probably find a couple of dozen examples of
people saying "why don't you just tell me, why go to the bother of
telling me it's in the FAQ", to quote somebody on a different topic
(canceling, and how to do so) "why can't you people give a straight
answer to a question".
--
John Moreno
------------------------------
Date: Mon, 22 Jun 1998 22:50:15 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Flames....
Message-Id: <1db1r58.j940urt9g6bhN@bay1-172.quincy.ziplink.net>
Lloyd Zusman <ljz@asfast.com> wrote:
> rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
>
> > Chris Miller <apminc@cvn.net> wrote:
> >
> > > It seems that newbies are comparable to flies around here. You tolerate
> > > them for awhile but you're annoyed to all hell by them. Lighten up a bit.
> > > Don't respond if you don't want to be bothered.
> >
> > If your house is infested with flies, don't pay any attention to them.
> > They'll go away. Really.
>
> Given that c.l.p.misc is a public, non-moderated newsgroup, I do not
> believe that anyone has the right to say that it's *their* house.
Okay then.
"If the public meeting area is infested with flies, don't pay any
attention to them. They'll go away. Really."
Better?
> And
> furthermore, given that the "newbies" who come here are human beings
> like everyone else, I also take strong issue with the insulting
> characterization of them as "flies".
Not my characterization, so I won't apologize for it. Anyway, it's just
an analogy. Don't get so worked up about it.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 22 Jun 1998 22:50:14 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Flames....
Message-Id: <1db1r35.12lds0tuavi3cN@bay1-172.quincy.ziplink.net>
<birgitt@my-dejanews.com> wrote:
> I would rather say they would go away immediately if they would
> be ignored, thus saving the rest of us to be distracted by flame
> exchanges.
Or they would post again, this time asking indignantly why they haven't
gotten an answer to their question. It's hard to say which will happen.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Mon, 22 Jun 1998 21:54:12 -0500
From: Tom Kent <tkent@pdq.net>
Subject: Hash iteration (trying to avoid looping through the entire hash)
Message-Id: <358F18D4.7EF0@pdq.net>
This script snippet allows me to parse a web server log and tell me how
many times each site was hit. However, I am unable to capture just the
top ten. Instead, I am only able to go through the entire hash. I've
tried counters and for loops in various places with no luck...Any ideas?
Thanks very much in advance.
@array = <SOMEFILE>
foreach $thisline (@array) {
($Fld1) = split (' ',$thisline);
push @words, ($Fld1);
}
foreach $word (@words) {
$count{$word} = $count{$word} + 1;
}
foreach $word (reverse sort occurrences keys %count) {
print "$count{$word} $word\n";
}
------------------------------
Date: Tue, 23 Jun 1998 02:21:43 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: More Complete Delete Example
Message-Id: <Pine.GSO.3.96.980622190833.3398S-100000@user2.teleport.com>
On Mon, 22 Jun 1998, Luckys wrote:
> Below is a better, working example of what I'm attempting to do. I
> don't understand why it won't delete the key, value pairs from the DMB
> file.
Okay, let's see whether we can get it to tell us.
> #!/usr/bin/perl
Add -w to check for warnings, and add a line enabling 'use strict'.
> $key1 = "name1";
> $value1 = "name1:\0:street_address:\0:etc";
To make these work under 'use strict', you'll need to declare your
variables. This line will do that; put it before the line in which you
first use any of them.
my($key1, $value1, $key2, $value2, %delete);
> $key2 = "name2";
> $value2 = "name2:\0:street_address:\0:etc";
>
>
> dbmopen(%delete, "delete", 0766);
This function tries to open the file, but it's up to you to check that it
succeeded. Remove that semicolon and add this line to check for errors.
or die "Can't dbmopen file 'delete': $!";
Also, are you sure you want your dbm file to have perms 0766? That's
odd...
> $delete{$key1} = "$value1";
> $delete{$key2} = "$value2";
Those double quote marks are merely misleading; remove them.
> dbmclose(%index);
>
>
> &DEL;
>
>
> # Open DBM file and delete key, value pair.
>
> sub DEL {
> dbmopen(%delete, "delete", 0766);
Once again, check for errors. Remove that semicolon and add this line:
or die "Can't dbmopen file 'delete': $!";
Also, if you're trying to open a dbm file which should already exist, you
probably want to use undef as the third parameter.
> foreach (keys %delete) {
>
> delete $delete{$_};
>
> }
Well, if you wish to delete the entire file, that's easier done in another
way! But, for testing purposes, this is fine.
> dbmclose(%index);
> }
With those changes to your program, do you find anything good? Hope this
helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 23 Jun 1998 02:25:18 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: More Complete Delete Example
Message-Id: <6mn3q2$ptt$2@ligarius.ultra.net>
[ posted and mailed ]
luckys@geocities.com wrote:
-> I'm sorry if my previous example was a bit inaccurate. I didn't me for
-> it to be a working example. I was more interest in the use of the
-> delete function.
Why didn't you just follow-up on the original thread instead of starting a
brand new one?
-> Below is a better, working example of what I'm attempting to do. I
-> don't understand why it won't delete the key, value pairs from the DMB
-> file.
Below is much worse than the original. You are assigning hashes to dbms and
then trying to work with a completely different hash. Granted, I haven't used
dbmopen and dbmclose since perl 4, I know that it doesn't change hash names in
the middle of the stream.
-> #!/usr/bin/perl
->
-> $key1 = "name1";
-> $value1 = "name1:\0:street_address:\0:etc";
->
-> $key2 = "name2";
-> $value2 = "name2:\0:street_address:\0:etc";
->
->
-> dbmopen(%delete, "delete", 0766);
You should be checking the status of your open. You can't do much if the open
didn't work correctly.
-> $delete{$key1} = "$value1";
-> $delete{$key2} = "$value2";
->
-> dbmclose(%index);
You assign a hash called %delete to a database named delete and then you close
%index.
>>> snipped <<<
Where is %index coming from?
Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
and let the jerk that answers know that his
toll free number was sent as spam. "
------------------------------
Date: Tue, 23 Jun 1998 02:14:24 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Pat space doesn't change in nested whiles
Message-Id: <EuzFK0.MMA@news.boeing.com>
In article <6mmqjt$6l0@milo.vcn.bc.ca>, John Yates <def456@vcn.bc.ca> wrote:
>I'm having a problem with the pattern space in nested whiles. The
>pattern space does not change when a second while <> reads in records.
>If I run this program:
>---------------------
> #!/usr/bin/perl
> while (<>) {
> print "In 1st while, \$_ = $_";
> while(<> && !m/bb/) {
> print " In 2nd while, \$_ = $_";
> }
> }
>
>With this data file:
>-------------------
>aaa1
>aaa2
>aaa3
>aaabb4
>ccc5
>ccc6
>ccbbcc7
>
>I get:
>------
>In 1st while, $_ = aaa1
> In 2nd while, $_ = aaa1
> In 2nd while, $_ = aaa1
> In 2nd while, $_ = aaa1
> In 2nd while, $_ = aaa1
> In 2nd while, $_ = aaa1
> In 2nd while, $_ = aaa1
>
>The records are read in but the m// doesn't find 'bb'.
>I can get around this by changing the program.
>
>I run this program:
>------------------
>#!/usr/bin/perl
>
>while (<>) {
> print "In 1st while, \$_ = $_";
> while(<>) {
> if (m/bb/) { goto OUT; }
> print " In 2nd while, \$_ = $_";
> }
>OUT:
>}
>
>And I get this result:
>---------------------
>In 1st while, $_ = aaa1
> In 2nd while, $_ = aaa2
> In 2nd while, $_ = aaa3
>In 1st while, $_ = ccc5
> In 2nd while, $_ = ccc6
>
>This is what is wanted. I am running perl version 5.004 under linux
>verion 2.0.30. Is there a better way to make the pattern space ($_)
>change in the second while (or make m// find bb)?
>
This is one of those tricky things until you read the
docs carefully:
man perlop and look for 'Evaluating a filehandle in angles'
The line:
while(<> && !m/bb/)
tosses out the result of <> because the <> isn't
the only thing in the while conditional. Again
read the man page thoroughly if this begins to
sound like gobbledegook.
So the usual remedy is to explicitly assign the <>
result:
while (defined($_ = <>) && !m/bb/)
Another possibility would be to defer the 2nd part of
the test:
while (<>) {
last unless !m/bb/;
HTH,
--
Charles DeRykus
------------------------------
Date: Mon, 22 Jun 1998 15:02:20 -0700
From: lisam@oreilly.com
Subject: Perl Position Papers due
Message-Id: <358ED46C.6992@oreilly.com>
Position Paper Deadline for the Perl Conference 2.0 "Workshop for
Developers" is July 1, 1998. Acceptances will be confirmed July 15.
This Workshop is led by Larry Wall, creator of Perl and will focus on
the organization and future direction of Perl Development. Send 1-page
position papers to: workshop@wall.org. For more info on the Workshop for
Developers, or the Perl Conference, see: http://conference.perl.com/
------------------------------
Date: Tue, 23 Jun 1998 02:07:37 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: Sick things to do in foreach loops
Message-Id: <358F0D30.55FC36A6@aquila.com>
Am I the only mere mortal sinner who finds this amusing?
Question: Should ALL Perl users, god and novitiate alike, be at 5.004_67
so that we will be at the same FAQing level?
Tom Christiansen wrote:
> psf@euclid.jpl.nasa.gov (Peter Scott) writes:
> :Er - WHICH perlsyn? Not the one that came with the Perl 5.004_04
>
> The one at 5.004_67.
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: Tue, 23 Jun 1998 01:57:01 GMT
From: nielson@macsch.com (Michael Nielson)
Subject: syswrite behavior on Win32
Message-Id: <EuzEr1.40H@draco.macsch.com>
Forgive me if this question has been asked before....
I'm seeing different behavior of the syswrite function when I compare
various versions of perl on Win32. Some versions (or builds?) will
convert the output string "\n" to "\r\n", some do not. For example, I
have a 5.002 executable that does not do the conversion. But I have a
5.004 binary that does.
Is this a Win32 "feature" that was introduced recently? Or is a
configurable build parameter?
--
=================================================================
Michael Nielson The MacNeal-Schwendler Corporation
michael.nielson@macsch.com Costa Mesa, California
Phone: (714) 444-5081
=================================================================
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". 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 2940
**************************************