[18631] in Perl-Users-Digest
Perl-Users Digest, Issue: 799 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 30 03:10:35 2001
Date: Mon, 30 Apr 2001 00:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988614611-v10-i799@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 30 Apr 2001 Volume: 10 Number: 799
Today's topics:
Re: Removing Lines... how's this? (BUCK NAKED1)
Re: Removing Lines... how's this? <uri@sysarch.com>
Re: Removing Lines... how's this? <uri@sysarch.com>
Re: Removing Lines... how's this? (Logan Shaw)
Re: Removing Lines... how's this? <monty@primenet.com>
Re: Removing Lines... how's this? <monty@primenet.com>
Re: Removing Lines... how's this? <bart.lateur@skynet.be>
Re: sendmail <wyzelli@yahoo.com>
Re: SGI IRIX fork() syscall: child process doesn't term <mischief@velma.motion.net>
Re: Should Perl be first? (Gwyn Judd)
Re: Simple newbie performance question (Logan Shaw)
Re: total newbie <mischief@velma.motion.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 29 Apr 2001 22:50:30 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Removing Lines... how's this?
Message-Id: <13383-3AECE106-94@storefull-245.iap.bryant.webtv.net>
> > BUCK NAKED1 wrote:
> > $log =3D~ s/(.*?)\n(.*?)\n(.*?)\n//;
> > print $log;
> bart.lateur@skynet.be (Bart=A0Lateur)
> The question marks and the parens are > unnecessary, as . doesn't
match a
> newline, and you're not interested in
> those lines themselves. So this will do:
>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0$log =3D~
s/^.*\n.*\n.*\n//;
Thanks for all the good examples that I can learn from; but I don't
understand why you said dot(.) won't match a newline, and yet you use
"." in your above example. And won't (dot). match a newline if used
with an "s" modifier. I read in perlre that dot(.) will match a newline
with the s modifier; but when I tried something like s/.{3}\n//s, it
didn't work, either. What am I missing?
Regards,
--Dennis
------------------------------
Date: Mon, 30 Apr 2001 05:27:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Removing Lines... how's this?
Message-Id: <x7hez7ez42.fsf@home.sysarch.com>
>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:
BN> Well, now I'm embarrassed. I completely forgot about perl's
BN> predefined variable "$.". I like the way you guys do it in one
BN> line. I gotta learn those some day. There's probably at least 10
BN> different ways to remove 3 lines. That may be good for some
BN> people, but perl would be less confusing to me if there was only
BN> one way to do something. The language would be smaller and perhaps
BN> run faster too. Well, I doubt if perl will change, so I guess I'll
BN> have to. :-)
have you seen the new python shirts? on the back it says, "there is only
one way to do it". well, they are right about that in python which is
why i use perl.
a major part of the skill of programming is how you choose a single
method from the multiple ways you can do something. it is where much of
the creativity lies. if a language handcuffs you and doesn't allow you
those choices, then it is not as useful for experienced coders. the
classic case is basic which had few features and was easy to learn but
almost impossible to do anything large in it. perl is designed for adult
programmers and not children. the sooner you learn that, the better a
perl hacker you will be.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: Mon, 30 Apr 2001 05:35:16 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Removing Lines... how's this?
Message-Id: <x7elubeyqj.fsf@home.sysarch.com>
>>>>> "BN" == BUCK NAKED1 <dennis100@webtv.net> writes:
>> bart.lateur@skynet.be (Bart=A0Lateur)
BN> s/^.*\n.*\n.*\n//;
BN> Thanks for all the good examples that I can learn from; but I
BN> don't understand why you said dot(.) won't match a newline, and
BN> yet you use "." in your above example. And won't (dot). match a
BN> newline if used with an "s" modifier. I read in perlre that dot(.)
BN> will match a newline with the s modifier; but when I tried
BN> something like s/.{3}\n//s, it didn't work, either. What am I
BN> missing?
but he uses an explicit \n to match \n. by allowing the . to not match
\n, he gets exactly 3 lines matched.
in fact he doesn't need the ^ as it will always use the first match it
finds.
your trial is wrong there. that looks for any 3 chars followed by a \n.
you don't seem to be grasping what is matching what. regexes have 2
active pointers, one in the regex and one in the data string. you have
to be aware of them both to design and understand regexes.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: 30 Apr 2001 00:38:46 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Removing Lines... how's this?
Message-Id: <9citp6$5ms$1@charity.cs.utexas.edu>
In article <x7hez7ez42.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
>have you seen the new python shirts? on the back it says, "there is only
>one way to do it". well, they are right about that in python which is
>why i use perl.
Well no, but the other day I did see a T-shirt that said this:
msdn.microsoft.com
COM+
Nothing Else Matters
Well, at least they're being up-front about their arrogance these
days...
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: 30 Apr 2001 06:27:46 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Removing Lines... how's this?
Message-Id: <9cj0l2$l3a$2@nnrp1.phx.gblx.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
> > bart.lateur@skynet.be (Bart Lateur)
> > > BUCK NAKED1 wrote:
> > > $log =~ s/(.*?)\n(.*?)\n(.*?)\n//;
> > > print $log;
> >
> > The question marks and the parens are > unnecessary, as . doesn't
> > match a newline, and you're not interested in
> > those lines themselves. So this will do:
> >
> > $log =~ s/^.*\n.*\n.*\n//;
>
> Thanks for all the good examples that I can learn from; but I don't
> understand why you said dot(.) won't match a newline, and yet you use
> "." in your above example. And won't (dot). match a newline if used
> with an "s" modifier. I read in perlre that dot(.) will match a newline
> with the s modifier; but when I tried something like s/.{3}\n//s, it
> didn't work, either. What am I missing?
Bart was exploiting a special property of the dot to express a
pattern that can be written more explicitly as
^[^\n]*\n[^\n]*\n[^\n]*\n
Here's the same regex expressed using an interval quantifier instead
of repeating the pattern:
^(?:[^\n]*\n){3}
Dot-star is idiomatic, but full of bugaboos. If it confuses or
frightens you, that's ok: you usually can (and often should) avoid
it by using negated characters classes instead.
Hmm... Has anyone ever suggested \N as the complement of \n and
analogue of, for example, \S? (I mean, besides me, just now.)
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: 30 Apr 2001 06:47:58 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: Removing Lines... how's this?
Message-Id: <9cj1qu$l3a$3@nnrp1.phx.gblx.net>
Uri Guttman wrote:
> Bart Lateur wrote:
> > $log =~ s/^.*\n.*\n.*\n//;
> ...
>
> in fact he doesn't need the ^ as it will always use the first match it
> finds.
Would ^ save futile match attempts for values of $log that contain
less than three (new)lines? Or is there an optimization that would
prevent needless match attempts after the value of $log was scanned
once? (What does Friedl call such an optimization? "Match length
cognizance"? I don't have MRE handy.)
--
Jim Monty
monty@primenet.com
Tempe, Arizona USA
------------------------------
Date: Mon, 30 Apr 2001 06:57:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Removing Lines... how's this?
Message-Id: <n33qet42mf33nob125up0lmtj9pbt8magb@4ax.com>
BUCK NAKED1 wrote:
>There's probably at least 10 different ways to remove 3
>lines. That may be good for some people, but perl would be less
>confusing to me if there was only one way to do something.
What if the way that it can be done would be the longest way imaginable?
The way that you'd never use if you possibly had a chance? Now you have
that chance.
Even with languages that let you do things only the way you want to,
there's still many different algorythms you can choose from to implement
sorting, simply because algorrythms are language independent. So, it
wouldn't solve anything.
--
Bart.
------------------------------
Date: Mon, 30 Apr 2001 14:19:33 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: sendmail
Message-Id: <bW5H6.9$lX5.1370@vic.nntp.telstra.net>
"Keith G" <gasper@cis.ohio-state.edu> wrote in message
news:9cimi7$ire$1@news.cis.ohio-state.edu...
> i'm looking for a way to get the sendmail module that will
> work with active perl for windows. anyone know of a
> site that has it? thanks!
> keith
A search for "sendmail for windows" on www.google.com gives over 1000 hits.
I guess one of those would be OK. I personally use the one you would get
from the "I'm Feeling Lucky" hit.
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";
------------------------------
Date: Mon, 30 Apr 2001 05:29:55 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: SGI IRIX fork() syscall: child process doesn't terminate after exit
Message-Id: <tepu2j3adg23eb@corp.supernews.com>
In comp.lang.perl.misc Brent Casavant <bcasavan@sgi.com> wrote:
> [posted and replied]
> On 25 Apr 2001, Matthew Black wrote:
>> PROBLEM:
>> We are having trouble with the fork() system call in Perl.
Really?
>> When a child process exits, the process lingers as
>> <defunct> rather than disappearing. These lingering
>> <defunct> processes disappear only after the parent
>> process gets terminated.
This is a problem of not waiting on the children. Learn
how to use the tools before you blame them for your
mistakes.
> Well, I'll admit to not being a Perl guru, but I'm
> pretty sure I know what the problem is.
> The parent process needs to catch the SIGCHLD signal,
Catching SIGCHGLD is not necessary, but this is a good
way to trigger a wait since it allows the wait to be
called in a timely manner and also allows the parent to
do other work instead of just blocking to wait on the
children.
> then perform a "wait()" system call to read the child's
> exit status. This is necessary because the kernel cannot
> free up the child's state (including the exit status)
> until somebody reads that exit status. You are observing
> child processes stuck in the "zombie" (not quite dead,
> not quite alve) state.
> The reason they go away when the parent exits is that
> the children are inheirited by the init process (pid 1),
> which always catches SIGCHLD and performs a wait(),
> causing the zombies to die for good.
Setting the value of $SIG{CHLD} to 'IGNORE' will allow
you to not worry about cleaning up after your children
on some platforms.
>> This problem was observed on our
>> Origin 200 systems running IRIX 6.5.x (6.5.10m and 6.5.6m).
>> It did NOT occur with a Challenge S running IRIX 6.2.
This is intgeresting. I will venture to say that the
Challenge S with IRIX 6.2 is the odd machine here, if
a Perl explanation indeed cannot be found. It's interesting
that people tend to think of what they know as being right
and what has changed to be wrong, even if this is in fact
directly opposed to reality and standards.
Chris
--
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997
------------------------------
Date: Mon, 30 Apr 2001 04:47:55 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Should Perl be first?
Message-Id: <slrn9eprjq.91u.tjla@thislove.dyndns.org>
"mein Luftkissenfahrzeug ist voll von den Aalen"
said Billy Chambless (bchambless@nrlssc.navy.mil) in
<9ci16v$qt2$1@news.datasync.com>:
>Could you point out exactly what it is I'm wrong about (just in the context
>of this thread, we don't have time to discuss ALL the ways I'm wrong. :) )
I misunderstood the meanng of what you were saying.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Nietzsche is dead.
-God
------------------------------
Date: 29 Apr 2001 23:10:01 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Simple newbie performance question
Message-Id: <9cioip$4qu$1@charity.cs.utexas.edu>
In article <NF4H6.820$Be3.85134@news.shore.net>,
Charles M. Kozierok <ixlu@PCGuide.com> wrote:
>In article <3AECCF03.C14292BD@stomp.stomp.tokyo>,
>Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>} I question
>} if you are in a position to present a logical debate regarding
>} a comparison and contrast of array looping and while looping.
>
>I said that I was new to Perl, but that I was not new to programming.
>
>I don't believe that there is anything particular to Perl that would
>make using an O(n) while loop to do multiple searches in a large
>file sensible.
Since you're new to the group, you might want to be aware that
Godzilla! seems to love to troll, or at least something like that.
Whatever it is that Godzilla! does, it doesn't seem to be ever be
productive to get into an argument with her.
- Logan
--
my your his her our their _its_
I'm you're he's she's we're they're _it's_
------------------------------
Date: Mon, 30 Apr 2001 04:43:44 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: total newbie
Message-Id: <teprc0h51vob7e@corp.supernews.com>
Chris Gunn <cgunn@bizynet.com> wrote:
> On Wed, 25 Apr 2001 16:45:39 GMT, gil@nospam-keskydee.com (Gil G.) wrote:
>>Hum... If you mean that an interpreter compiles on the fly, sure...
>>As to perly.y, enlight me please..
> Howdy Gil,
> Everytime your script is executed, Perl verifies its okay
True.
> and then compiles an executable in memory.
False, at least for the meaning of 'executable' you
seem to want.
> Why they seem to be unwilling to write that to hard
> drive as an .exe is beyond me.
Unwilling? Is that why there are multiple different
projects going on to provide a machine-language
target for Perl compilers?
Who is 'they'? Have Mulder and Scully been called in
on this?
Have you considered that the 'executable' into which
your program is compiled needs to be directly linked
to the Perl system to work? Have you considered that
your Perl program, since it is capable of dynamically
altering itself, may be difficult to compile to a
static machine-language image? Have you considered
that a compiler often does not deal with a machine
language target? Have you considered that using a
machine-language target slows down the process of
porting a compiler from platform to platform? Have you
ever read the docs for the dump function? Have you ever
noticed that you can compile Perl in the sense you mean
using the right tools (although not very well all the
time just yet)?
Have you ever read a book on compiler design or
implementation? Have you ever read a book on
portability? Have you ever read a book on parsing
and lexing? Have you ever created a symbol table or
a parse tree in a program? What you assume is so
easy is not. The design goals of Perl and perl do
not state that they be able to produce a Windows
executable that runs on its own.
Perl is a portable language, and perl is a
portable system to run Perl. You can't just
assume it's so easy to make machine-language,
memory-loadable files for 40 or 50 platforms.
It's hard enough to make the compiler itself
compile on as many platforms as it does.
> Mostly I think they want your source code to
> be available to borrow whenever anyone wants to.
Have you ever heard of copyright? It would cost me
a lot more money to fight a lawsuit over copyright
infringement on a clear-text source than it would
to reverse engineer a binary 'executable' file ready
for the OS's loader.
> Chris
Blech. Perhaps I should sign my full name all the time.
Before you make such strong statements belitting the
character of others, perhaps you should have some
clue where to go to beg a hint about how to develop
some fraction of an idea relevant to what is involved
in the topic about which you speak.
Chris Stith
--
Parking for people we like only. All other
vehicles will be vandalized.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 799
**************************************