[9260] in Perl-Users-Digest
Perl-Users Digest, Issue: 2855 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 12 13:15:31 1998
Date: Fri, 12 Jun 98 10:00:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 12 Jun 1998 Volume: 8 Number: 2855
Today's topics:
Re: *Simple* MakeMaker question (Abigail)
Re: Associating Perl with .pl in CGI <nguyend7@egr.msu.edu>
Re: Certified Perl Programmers (Danny Aldham)
Re: Certified Perl Programmers <tchrist@mox.perl.com>
changing install location with search/replace justin_lloyd@my-dejanews.com
Re: Command line substitution thru subdirectories <ngouah@erols.com>
Re: Command line substitution thru subdirectories (Brad Murray)
Re: Command line substitution thru subdirectories (Brad Murray)
Re: Command line substitution thru subdirectories <tchrist@mox.perl.com>
COMPARING TIME & DATE <thijs@esense.nl>
ending a foreach loop <kthor@idt.net>
Re: Have we got a good free Perl manual? (Chris Howard)
Re: Have we got a good free Perl manual? (Abigail)
Re: Have we got a good free Perl manual? <tchrist@mox.perl.com>
Re: Have we got a good free Perl manual? <barmar@bbnplanet.com>
Is this insane? (Steve Vertigan)
Re: Is this insane? (Mike Whitaker)
Re: lambda fun in Perl <xah@shell13.ba.best.com>
Loop question <phengl@ir-optima.com>
Re: Most common element of array. (Jahwan Kim)
Re: pack/unpack seps <rs83@is7.nyu.edu>
Re: pack/unpack seps <tchrist@mox.perl.com>
Re: pass the gravy and the hashref, please -- solved <sengle1@umbc.edu>
Re: pass the gravy and the hashref, please -- solved <sengle1@umbc.edu>
perl and recursion? <wentzel@umr.edu>
Re: perl and recursion? (Michael J Gebis)
Re: perl math accuracy <gnat@frii.com>
Re: Prob in FAQ: Week of the year (Nicholas Carey)
Re: Prob in FAQ: Week of the year <tchrist@mox.perl.com>
Re: question on a process mgmt (how to kill a child pro <vallon@bear.com>
Re: question on a process mgmt (how to kill a child pro <tchrist@mox.perl.com>
Re: Subs and References and implicit arguments (Mike Stok)
Re: Subs and References and implicit arguments <demaille@inf.enst.fr>
Re: Subs and References and implicit arguments (Mike Stok)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jun 1998 16:16:05 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: *Simple* MakeMaker question
Message-Id: <6lrk85$la$2@client3.news.psi.net>
Zenin (zenin@bawdycaste.org) wrote on MDCCXLVI September MCMXCIII in
<URL: news:897618013.315322@thrush.omix.com>:
++ [posted & mailed]
++
++ John Siracusa <macintsh@cs.bu.edu> wrote:
++ : I'm creating a Perl module that consists of some .pm files and
++ : some .pod files. I want to install this module by typing:
++ : perl Makefile.PL
++ : make
++ : make install
++ >snip<
++
++ h2xs -AX -n My::Module
++
++ Always, always, always start with h2xs when creating
++ new modules, even if you're not using any C.
You talk as if h2xs is a nifty tool!
$ h2xs -AX -n My::Module
Writing My/Module/Module.pm
Writing My/Module/Makefile.PL
Writing My/Module/test.pl
Writing My/Module/Changes
Writing My/Module/MANIFEST
$ perl -c -MMy::Module -e0
Can't locate My/Module.pm in @INC (@INC contains: /home/abigail/Scripts /home/abigail/Perl /nfs1/local/lib/perl5.00404/sun4-solaris/5.00404 /nfs1/local/lib/perl5.00404 /nfs1/local/lib/perl5.00404/site_perl/sun4-solaris /nfs1/local/lib/perl5.00404/site_perl .).
BEGIN failed--compilation aborted.
$
Blech.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 12 Jun 1998 14:54:36 GMT
From: Dan Nguyen <nguyend7@egr.msu.edu>
Subject: Re: Associating Perl with .pl in CGI
Message-Id: <6lrffd$8pe$1@msunews.cl.msu.edu>
Brian P. Barnes <brian.barnes@tfn.com> wrote:
[snip]
: it from Netscape with the URL:
: http://brianb/cgi-bin/image.plx
[snip]
: I have also tried changing the extension from ".plx" to ".pl" to give it
: the standard Perl extension without success.
Try removing the extension. If your config is correct it'll execute
the script.
--
Dan Nguyen |
nguyend7@cps.msu.edu | Remember Byron.
http://www.cps.msu.edu/~nguyend7 |
------------------------------
Date: 12 Jun 1998 05:08:39 GMT
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: Certified Perl Programmers
Message-Id: <6lqd4n$7h2$1@lennon.postino.com>
X-Newsreader: TIN [version 1.2 PL2]
>
>I encourage everyone else to do this too. You can certify yourself,
>or you can send email to mjd-perl-certification@plover.com to request
>a certification, which I will send. Then you can bill yourself as a
>`Plover Systems Certified Perl Programmer' or just `Certified Perl
>Programmer'. I encourage the latter---it would be bad if there was
>some way to distinguish free certifications from the kind you have to
>pay for.
>
Does this Certification come with a snappy wall plaque? I really want
a snappy wall plaque. With a picture of a Camel on it.
I seem to remember reading something about Larry being certified before
Perl. But I think that cert comes with a shirt with really long sleeves.
Don't think I'm interested it that.
--
Danny Aldham
------------------------------
Date: 12 Jun 1998 16:10:15 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Certified Perl Programmers
Message-Id: <6lrjt7$jqr$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
danny@lennon.postino.com (Danny Aldham) writes:
:But I think that cert comes with a shirt with really long sleeves.
No, certs come with retsin.
--tom
--
I'll say it again for the logic impaired.
--Larry Wall
------------------------------
Date: Fri, 12 Jun 1998 15:02:55 GMT
From: justin_lloyd@my-dejanews.com
Subject: changing install location with search/replace
Message-Id: <6lrfuv$fdo$1@nnrp1.dejanews.com>
I have been testing out serving both 5.003 and 5.004 for Irix and Solaris. My
tests seem to be going well. Here's how I have it set up:
Perl's entry in the auto_IStest NIS map:
perl -rw,intr,soft \ / hyperion:/export/PUB/PERL_SW/PERL_DIR \
/5.003/bin hyperion:/export/PUB/PERL_SW/$OSNAME/5.003/bin \ /5.004/bin
hyperion:/export/PUB/PERL_SW/$OSNAME/5.004/bin
Here's the physical directory structure:
/export/PUB/PERL_SW/PERL_DIR/5.003/bin (empty mount point)
/export/PUB/PERL_SW/PERL_DIR/5.003/lib
/export/PUB/PERL_SW/PERL_DIR/5.003/man
/export/PUB/PERL_SW/PERL_DIR/5.004/bin (empty mount point)
/export/PUB/PERL_SW/PERL_DIR/5.004/lib
/export/PUB/PERL_SW/PERL_DIR/5.004/man
/export/PUB/PERL_SW/PERL_DIR/bin -> 5.004/bin
/export/PUB/PERL_SW/PERL_DIR/lib -> 5.004/lib
/export/PUB/PERL_SW/PERL_DIR/man -> 5.004/man
/export/PUB/PERL_SW/SunOS/5.003/bin
/export/PUB/PERL_SW/SunOS/5.004/bin
/export/PUB/PERL_SW/IRIX/5.003/bin
/export/PUB/PERL_SW/IRIX/5.004/bin
When I installed from both Solaris and Irix, I simply did a 'make install' to
/IStest/perl/5.004. So my question is: Is it simple enough to move all of
this from /IStest/... to /pub/... with a global search-replace?
% pwd
/export/PUB/PERL_SW
% perl -pi -e 's/IStest/pub/g'
I tested this without the -i option to see what would come out, and everything
looked OK, including the modules I've installed (CGI, Tk, LWP, etc.), but
could I be missing something?
And a question for the perl5-porters (great list, I've been learning a lot
just by being a passive subscriber for a couple of weeks now): How could this
hierarchy be affected by any @INC reorganization in 5.005?
Thanks,
JcL
jlloyd/AT/harris/DOT/com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 12 Jun 1998 11:26:13 -0400
From: Ngouah A Nguiamba <ngouah@erols.com>
Subject: Re: Command line substitution thru subdirectories
Message-Id: <35814895.6FE7@erols.com>
jimbo@soundiamges.co.uk wrote:
>
> Tom Christiansen <tchrist@mox.perl.com> writes:
>
> > In comp.lang.perl.misc,
> > dsdapc03@DSDAPC03.okladot.state.ok.us (OS2 User) writes:
> > :A really _great_ way to attract business to a Perl consultancy.
> > :Maybe you should go into advertising, too. And Human Relations
> > :also might be a good choice.
> >
> > I prefer to be a real person with real opinions who doesn't lie just
> > because it suits his pocket book and becomes a money-grubbing pig who
> > changes his words into lies to try to get more people to kiss his behind
> > and ante up. I won't do that. I do Perl because it's fun, not because
> > I want to become the next billgatesionaire. If you can't take the heat,
> > get out of the kitchen.
>
> Tom, what's the particular issue with money? What's the particular
> issue with Bill Gates? Do you honestly think that Bill is any less
> motivated by the same convictions that you are?
[snip]
>
> Do you think that it is wrong to earn money, of any sum, from
> promoting your company and products and philosophies in the commercial
> arena?
Any sum ? Hell yes, that might be wrong. Absolute power will always
be ab- or misused, be it political or economical power. Even with the
best intentions, the wisdom of one human being is not enough to be
immune against it.
Why care ? The destiny of any powerful status is to loose it. Just a
matter of time.
Ooops, I will vote for moderated to prevent this group from my own
off topic posts. This .misc is just too seductive. 8-)
Birgitt Funk
------------------------------
Date: 12 Jun 1998 08:09:23 -0700
From: murrayb@vansel.alcatel.com (Brad Murray)
Subject: Re: Command line substitution thru subdirectories
Message-Id: <6lrgb3$in@cadre2.vansel.alcatel.com>
It seems Scratchie suggested...
>So your advice to perl beginners on the Wintel platform is that they write
>their own versions of any unix utility they need?
If necessary. As per my previous post, however, it is *not* necessary. You
may have to do some research, though, which is an activity that I see very
little motivation for around here at times. Don't you folks *like* figuring
things out? I thought that was a hallmark of all good programmers.
--
Brad Murray "The fall of modern man will be preceded by the
Software Analyst de-evolution of communications to the days of
Alcatel Canada oral tradition." --Tom Christiansen paraphrased
------------------------------
Date: 12 Jun 1998 07:36:35 -0700
From: murrayb@vansel.alcatel.com (Brad Murray)
Subject: Re: Command line substitution thru subdirectories
Message-Id: <6lredj$hd@cadre2.vansel.alcatel.com>
It seems Scratchie suggested...
>So your advice to perl beginners on the Wintel platform is that they write
>their own versions of any unix utility they need?
If you expend a little energy and a modest amount of brain-power, you will
find that most if not all of the unix tools that Tom refers to are available
(albeit frequently in crippled for, but no more crippled than many commercial
Unix distributions provide) for most platforms. Certainly I have found
near-complete toolkits for Win32, OS/2, and VMS.
It behooves you to ensure that you have a complete toolset before attempting
to use any language that assumes them. To me, that means perl, but also
C, C++, and almost every other language I have been tricked into working
with in the past. Even Visual Basic has occasionally benefited from bulk
filtering source files in my experience. Your mileage may vary, but if it
does you had best pray that you never get caught without an IDE---and the
real world is full of examples where the IDE is not used or is used
sparingly. High paying places, no less, if such things are of interest to
you.
It is also a sad but true fact that if you master the toolkit, you will look
like a genius next to your floundering compatriots. You will solve problems
while they are on the phone to text support or purchasing. This can also
be humorous.
--
Brad Murray "The fall of modern man will be preceded by the
Software Analyst de-evolution of communications to the days of
Alcatel Canada oral tradition." --Tom Christiansen paraphrased
------------------------------
Date: 12 Jun 1998 15:59:46 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Command line substitution thru subdirectories
Message-Id: <6lrj9i$jqr$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, murrayb@vansel.alcatel.com writes:
:Don't you folks *like* figuring
:things out? I thought that was a hallmark of all good programmers.
You forget: In this age of Cultural Relativism and Microsoft Innovation
and Z=-2 across the board standards, we are now exected to nurse along
even cripplingly bad programmers.
We could just let Darwin takes its course and let them implode, but it's
probably better to just nip them in the bud before they can go to seed
and spread mediocrity.
Just as the top 5% make 90% of the contributions, the bottom 5% will
take up 300% of your time--if you let them. So don't do that. They
must find their own way, or die on the vine.
--tom
--
I already have too much problem with people thinking the efficiency of
a perl construct is related to its length. On the other hand, I'm
perfectly capable of changing my mind next week... :-) --lwall
------------------------------
Date: 12 Jun 1998 15:07:13 GMT
From: "Mathijs Oosterom" <thijs@esense.nl>
Subject: COMPARING TIME & DATE
Message-Id: <01bd9613$d4f03920$a44a6dc2@earl.esense.nl>
Hi all,
In a temp-file on my Linux-server I have a date & time written. In a
certain Perl-script I want to determine the difference between the date &
time in the temp-file and the current date & time.
Of course this can be done by writing a routine that does a lot of
calculations, but I wonder if there is a better and faster way to do it.
Maybe there's some sort of function for this?
All help will be appreciated, thanx in advance,
Thijs.
------------------------------
Date: Fri, 12 Jun 1998 12:28:57 -0400
From: Kevin Thorley <kthor@idt.net>
Subject: ending a foreach loop
Message-Id: <35815749.4031@idt.net>
I'm using the following lines of code to search an array line by line
for a given string. When I find the string though, I don't want to
continue searchin (it will only appear once). Can I break out of a
foreach loop, or should I be using another type of loop.
foreach (@DATA){
if (! m/^\#/) {
if (m/^$file_name/){
split(/\t+/);
}
}
Kevin Thorley
kthorley@mpgnews.com
------------------------------
Date: 12 Jun 1998 15:10:35 GMT
From: choward@intellistor.com (Chris Howard)
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6lrgdb$og6$1@news.intellistor.com>
David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> writes:
>lehman@visi.com (Todd Lehman) writes:
>> rms@gnu.org (Richard Stallman) writes:
>> > Once upon a time, I thought I would learn Perl. I got a copy of a
>> > free manual, but I found it simply unreadable, and gave up. Perl
>> > users told me that there were better manuals, but they were not free.
>>
I'm sorry, I just can't work up much ire for O'Reilly and Assoc.
Twelve years ago I started buying and reading their nutshell
handbooks. At the time, they were about the only source of
useful information apart from vendor manuals. They were particularly
good at comparing different versions of similar software/commands
on various Unix systems. They've helped me tremendously. Many times.
Where would we be without their books on Sendmail, DNS, UUCP?
I thought one of the ways it was PC to make a living was to
provide support and documentation for "Free" software.
(Is it ok if a guy writes a paid-for article for a magazine
about e.g. gcc?) Will Cygnus get hammered for providing
"not free" support?
On the philosophical side: Isn't all *good* documentation
written from a stand of knowledge and authority? Doesn't
that mean that you don't want every little dofus making
changes to the docs? So *good* documentation is
==NOT FREE== in the FSF sense.
RMS himself is a good example. When he posts to this newsgroup
through someone else... nobody reads it. But when he
posts as himself, then people read it to see what he has to
say. There's an interest in his *authoritative point of view*.
When Larry Wall says "this is the way Perl works", you listen.
A manual on Perl that can be mangled on a whim is not authoritative
and therefore not much better than using Dejanews on comp.lang.perl
We already have newsgroups. Documentation should be more than
a compilation of rumors.
--
Chris Howard Fujitsu Computer Products of America
Longmont, Colorado
------------------------------
Date: 12 Jun 1998 15:53:32 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6lrits$la$1@client3.news.psi.net>
David Kastrup (dak@mailhost.neuroinformatik.ruhr-uni-bochum.de) wrote on
MDCCXLVI September MCMXCIII in <URL: news:m2emwuq450.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>:
++ lehman@visi.com (Todd Lehman) writes:
++
++ > rms@gnu.org (Richard Stallman) writes:
++ > > Once upon a time, I thought I would learn Perl. I got a copy of a
++ > > free manual, but I found it simply unreadable, and gave up. Perl
++ > > users told me that there were better manuals, but they were not free.
++ >
++ > It seems odd to deny oneself the pleasure of learning a new language for
++ > several years simply because someone tells you that the best documentation
++ > isn't freely available.
++
++ If you are learning the language for pleasure, you might want to
++ acquire non-free books. If you want to learn the language in order to
++ use it for programming free software, the non-existence of good free
++ documentation will block a lot of possible contributors from helping.
++ That's not what free software is about. Do you have an idea how
++ expensive a "cheap" American book comes, for example, to an average
++ former Soviet programmer?
If you think there doesn't exist good free (even in the FSF sense)
documentation for Perl, you are very, very mistaken. The FAQ has this
license everyone is falling over on (Tom has indicated he is working
on a solution). I'm not aware of any book publishing the FAQ. I cannot
imagine the FAQ is a requirement to learn Perl. On the other hand,
almost anything that appears in the Camel - *the Perl reference book*
- appears in the man pages distributed under GPL & AL. Except the Camel
is a year and a half old and the man pages are up to date.
++ > > Why was this? Their authors had sold the manuals to O'Reilly, instead
++ > > of contributing them to the free software community.
Eh? You pay a fee to O'Reilly if you want the manuals printed out on
nice paper, and have them wrapped up in a cover with a Camel on it.
Just the fact O'Reilly printed out the manuals does not mean the manuals
are no longer available.
++ > But it was their choice.
++ >
++ > > It wasn't the
++ > > first time and (to our community's great loss) it was far from the
++ > > last.
++ >
++ > It was their choice. To suggest that it was a loss to the community is
++ > to say that they were under some cosmic obligation to contribute free
++ > documentation for the free software they created.
++
++ This is nonsense. It is a loss to the community period. If they were
++ under some cosmic obligation, the community would not encounter any
++ loss because it could sue them for providing the stuff. As they are
++ not under an obligation, it is a loss to the community for good.
++
++ For that reason, RMS has put good free books about Perl on the task
++ list. He has not put any demands on anybody to take this up. He has
++ been flamed beyond sanity and called all sorts of names like "liar",
++ "hypocrite", "evil", "Bill Gates of free software" and whatever,
++ however, for *daring* to put something like that on the task list.
++
++ >
++ > > Perl is an important piece of free software, and it ought to have a
++ > > *good* free manual.
++ >
++ > I share the same *opinion*, but where does "ought to" come from? Says who?
++ > Someone ought to sit down and spend gobs of their own spare time writing a
++ > good free manual because someone unwilling to buy a non-free manual said so?
++ > (Titles aside, that's what it comes down to, doesn't it?)
++
++ Yes. That's how free software usually happens. That's why it is in
++ the task list. Quite accurately observed.
++
++ > You should face the simple fact that you failed to motivate someone out
++ > there to write what you wanted them to write.
++ >
++ > But there is nothing wrong with that. You just need to try again -- perhaps
++ > from a different angle -- or perhaps delegate the broader task -- enlist
++ > someone who can drum up the enthusiasm and provide the needed
++ > motivation.
++
++ That's why it is in the task list. Which is why he was flamed beyond
++ belief.
++
++ > > What they can't be is part of the free software
++ > > community.
++ >
++ > I would argue that the O'Reilly Perl books and TPJ are in fact very much a
++ > part of the free software community (w.r.t. Perl) as they document a piece
++ > of free software.
++
++ They are not part of the free software community because nothing free
++ ever comes back from them. Documentation by them is as much part of
++ the free software community as dandruff is part of my body: initially
++ very close, it nevertheless does not contribute anything to any living
++ cells of me and will eventually in its unchanged state fall off. It
++ is associated to free software, but is not part of the community.
++
++ > Does not the free software community extend far beyond
++ > the simple set of things which are free?
++
++ Nope. Free software community is the people working on free
++ software. A bar is not part of the mining industry even when it keeps
++ alive by being visited by miners.
Community? If this bickering is part of the "free software community",
I'd rather buy software.
Abigail
--
Note to self: never release anything again under GPL.
------------------------------
Date: 12 Jun 1998 16:08:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <6lrjqp$jqr$3@csnews.cs.colorado.edu>
>From the Artistic Licence:
"Freely Available" means that no fee is charged for the item itself,
though there may be fees involved in handling the item. It also
means that recipients of the item may redistribute it under the same
conditions they received it.
"Reasonable copying fee" is whatever you can justify on the basis of
media cost, duplication charges, time of people involved, and so on.
(You will not be required to justify it to the Copyright Holder,
but only to the computing community at large as a market that must
bear the fee.)
--tom
--
You know, by the time you get done with all this, the "Swiss Army
Chainsaw" is going to be more like a Swiss Army Tactical Nuke.... :-)
--Brandon Allbery on perl in <1991Feb21.002412.20045@NCoast.ORG>
------------------------------
Date: Fri, 12 Jun 1998 16:31:45 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <RJcg1.111$Fr5.1316181@cam-news-reader1.bbnplanet.com>
In article <8H4g1.874$bj2.4289526@ptah.visi.com>,
Todd Lehman <lehman@visi.com> wrote:
>
>rms@gnu.org (Richard Stallman) writes:
>> Once upon a time, I thought I would learn Perl. I got a copy of a
>> free manual, but I found it simply unreadable, and gave up. Perl
>> users told me that there were better manuals, but they were not free.
>
>It seems odd to deny oneself the pleasure of learning a new language for
>several years simply because someone tells you that the best documentation
>isn't freely available.
>
>Was the decision a personal monetary issue or a moral issue?
>
>For serious work, a Perl library of about 10 good titles costs around $300.
>But you can get started for a small investment of $30 or $40, depending on
>which book you choose. Alternatively, perhaps a friend or relative could buy
>you _Programming_Perl_ or _Learning_Perl_ as a gift.
What does money have to do with this discussion? If you've read this
thread, you should know that when RMS says "free" he refers to freedom to
share and modify, not price.
For RMS, it's clearly a moral issue. He considers himself a vanguard of
the free software movement, and insists on using free software as much as
feasible. When he needs software for a task and can't find a free version,
he writes it himself or encourages others to do so.
--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
------------------------------
Date: Fri, 12 Jun 1998 23:31:28 +0800
From: steve@vertigan.iinet.net.au (Steve Vertigan)
Subject: Is this insane?
Message-Id: <199806121531.XAA08685@opera.iinet.net.au>
Hi. I've just written a spiffy (cgi/linux) application that my boss wants
me to get running on an NT server that doesn't have a Perl interpreter
installed. It occurred to me that one way would be to compile the Perl code
into C using the compiler and then to compile that C using the GNU compiler
for win32. 10 hours and one miserly test.c file that wont compile later I'm
starting to wonder if it was such a brilliant idea after all. Has anyone
managed to do something like this successfully or is there an easier way to
do things?
Any help/advice/career changes, much appreciated!
--Steve
------------------------------
Date: 12 Jun 1998 15:40:22 GMT
From: mrw@malay.entropic.co.uk (Mike Whitaker)
Subject: Re: Is this insane?
Message-Id: <slrn6o2iot.ger.mrw@malay.entropic.co.uk>
On Fri, 12 Jun 1998 23:31:28 +0800,
Steve Vertigan <steve@vertigan.iinet.net.au> wrote:
>Hi. I've just written a spiffy (cgi/linux) application that my boss wants
>me to get running on an NT server that doesn't have a Perl interpreter
>installed. It occurred to me that one way would be to compile the Perl code
>into C using the compiler and then to compile that C using the GNU compiler
>for win32. 10 hours and one miserly test.c file that wont compile later I'm
>starting to wonder if it was such a brilliant idea after all. Has anyone
>managed to do something like this successfully or is there an easier way to
>do things?
>
>Any help/advice/career changes, much appreciated!
Install Perl for NT.
You won't regret it.
And, no, I'm not being facetious. In the 10 hours you've spent, you
could have a working NT Perl talking to IIS and running CGI's.
--
Mike Whitaker: Sysadmin, Entropic Cambridge Research Labs
------------------------------
Date: 12 Jun 1998 09:41:49 -0700
From: Xah Lee <xah@shell13.ba.best.com>
Subject: Re: lambda fun in Perl
Message-Id: <yo3pvgeinch.fsf@shell13.ba.best.com>
Xah Lee wrote:
>
> Is there a way to sequence pure functions without
> using a nesting notation such as the following?
>
> sub{sort @_;} ->
> (sub{map {$_/2} @_;}->
> ( sub {reverse @_;}->
> ( sub {map {$_ *2} @_; } ->
> (1..4))));
John Porter <jdporter@min.net> writes:
> Um, any reason why that is to be prefered over, say,
>
> sort
> map { $_ / 2 }
> reverse
> map { $_ * 2 }
> (1..4);
Interesting example that caused me to think a bit. I think the reason
is analogous to "why are there purely functional languages while we
could program functionally in existing languages?".
In the above case, if I string
a sequence of functions, I can copy and paste worry-free. Otherwise, I'd have to
worry about side effects. Lambda calculus is what I want to line up
to...
Is there a way to sequence functions without nesting notation?
Xah, xah@best.com
http://www.best.com/~xah/MathGraphicsGallery_dir/Tiling_dir/tiling.html
"Tumor growth and variations: Unix C C++ sed awk sh csh Perl"
------------------------------
Date: 12 Jun 1998 16:13:13 GMT
From: "Pheng Lay" <phengl@ir-optima.com>
Subject: Loop question
Message-Id: <01bd961c$c1b29980$5090d9cf@pheng-lay>
I'm trying to get a list of user names from the FirstName field in the SQL
database, but I could only get the first FirstName on the list. Does
anyone know how to loop thru this and get the complete list of all the user
names? Thanks.
phengl@ir-optima.com
------------------------------
Date: 12 Jun 1998 16:40:38 GMT
From: jahwan@lilac.engin.umich.edu (Jahwan Kim)
Subject: Re: Most common element of array.
Message-Id: <slrn6o2n8p.uq.jahwan@lilac.engin.umich.edu>
On 12 Jun 1998 12:33:37 GMT, Mike Whitaker <mrw@malay.entropic.co.uk> wrote:
[snip]
>
> #!/usr/bin/perl -w
>
> use strict;
> use diagnostics;
>
> sub most_common {
> my %count;
> foreach (@_) { $count{$_}++; }
> (sort { $count{$b} <=> $count{$a} } keys %count)[0];
^^^^
Not the fastest way... If we had the 'extremum' function which has the
same syntax as sort as someone suggested in the group sometime ago, I'd
replace sort by that. Sorry, don't have a patch.
[snip]
Jahwan
------------------------------
Date: Sat, 13 Jun 1998 11:45:11 -0400
From: Ruben I Safir <rs83@is7.nyu.edu>
Subject: Re: pack/unpack seps
Message-Id: <35829E86.EDE4E502@is7.nyu.edu>
>
I have a data file I need to parse, and UNPACK(a) and UNPACK(c) returns
different
results. If I have a byte with is 219 in OCT - I wanted to know if it
is represented different in c or a - What does it do, it looks at the
byte and interprets it to an ascii representation of a integrer or what.
I guess I've been answered this now in that c returns a "number:" in the
string which is returned in unpack, while a1 returns a one char string.
This makes me wonder what use c would be?
I would hope the docs would say something like:
unpack c looks at the next byte and intrepts it as an unsigned int which in
sclar context is printed as a number....
Or something like that.
Ruben
------------------------------
Date: 12 Jun 1998 16:07:01 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: pack/unpack seps
Message-Id: <6lrjn5$jqr$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Ruben I Safir <rs83@is7.nyu.edu> writes:
: I have a data file I need to parse, and UNPACK(a) and UNPACK(c) returns
:different
:results.
You have just exhausted your alotted quota of repeating the same question
again and again, and continuing to fail to understand despite innumerable
private and public answers. Since it's obvious that we are all too
stupid to understand how to help you, I think it's time for you to to
use your own brain to uncover these answers empirically.
5% -> 300%
--tom
--
The Unix Way of doing something [...] is to make it look as much like a filter
as possible. (Richard O'Keefe)
------------------------------
Date: Fri, 12 Jun 1998 11:26:44 -0400
From: Scott Englehart <sengle1@umbc.edu>
Subject: Re: pass the gravy and the hashref, please -- solved
Message-Id: <358148B3.39AF69F0@umbc.edu>
> You might want to consider:
>
> %{$self->{values}}= %$href;
>
> it does the same thing as your while() would do if you preceeded it by:
>
> %{$self->{values}}= ();
Thanks for the info. I was about to post the same problem when I saw your
answer.
------------------------------
Date: Fri, 12 Jun 1998 12:08:32 -0400
From: Scott Englehart <sengle1@umbc.edu>
Subject: Re: pass the gravy and the hashref, please -- solved
Message-Id: <3581527F.5CE9843C@umbc.edu>
But yet another problem.
Why does this work:
foreach $key (@keys){
print $this->{'stopped_content'}->{$key};
}
But this:
while ( ($k, $v) = each $this->{'stopped_content'}->{} ){
print $v;
}
does not run:
syntax error at STOP_COUNT.pm line 89, near "{}"
BEGIN failed--compilation aborted at simple line 16.
------------------------------
Date: Fri, 12 Jun 1998 10:22:38 -0500
From: Michael Wentzel <wentzel@umr.edu>
Subject: perl and recursion?
Message-Id: <358147BE.73EDCF0@umr.edu>
Does perl allow recursion? In other words, does this work?
sub update_totals
{ ...
if ($filename ne "") { &update_totals; }
...
}
If anyone can help me with this or point me in the right direction I
would appreciate it. Thanks.
------------------------------
Date: 12 Jun 1998 16:35:45 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: perl and recursion?
Message-Id: <6lrld1$edr@mozo.cc.purdue.edu>
Michael Wentzel <wentzel@umr.edu> writes:
}Does perl allow recursion? In other words, does this work?
}sub update_totals
} { ...
} if ($filename ne "") { &update_totals; }
} ...
} }
#!/usr/local/bin/perl -w
#pragma DWIM
sub fact {
my($x)=@_;
if($x ==1) {return 1;}
else {return $x * fact($x-1);}
}
print fact(5);
Can you tell me if that prints 120?
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 12 Jun 1998 10:16:48 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: perl math accuracy
Message-Id: <5q7m2mmw7j.fsf@prometheus.frii.com>
Dave Hutchins <djhutchx@co.intel.com> writes:
> I can not find any reason why simple operations in perl return
> inaccurate results,
> such as (12 - 11.96) != 0.04
>
> bc and awk return the correct results:
bc uses an arbitrary precision library, because speed isn't
important with bc. awk *doesn't* get it right, because your test was
wrong:
gnat@coprolith (/tmp) awk 'BEGIN{ if (12 - 11.96 != 0.04){ print "floats are not reals\n" } exit}'
floats are not reals
C, however, does not:
gnat@coprolith (/tmp) cat test.c
#include <stdio.h>
main() {
float a, b, c;
a = 12.0;
b = 11.96;
c = 0.04;
printf("%f - %f %s %f\n", a, b,
(a - b == c) ? "==" : "!=",
c);
}
gnat@coprolith (/tmp) cc -o test test.c
gnat@coprolith (/tmp) ./test
12.000000 - 11.960000 != 0.040000
Perl and awk use C's floats (well, double floats, but same principle)
to represent numbers, so has the same problems.
> does anyone have a simple answer?
There are an infinite number of real numbers. Floating point numbers
have a fixed number of bits, so obviously you can't precisely
represent every real number. What you have to do is either use an
arbitrary precision library as bc does (Math::BigFloat in Perl) or
decide on the number of decimal places that are important and compare
to that many places.
Nat
------------------------------
Date: Fri, 12 Jun 1998 09:29:11 -0700
From: ncarey@harlequin.com (Nicholas Carey)
Subject: Re: Prob in FAQ: Week of the year
Message-Id: <MPG.feaf735eea90f33989682@newshost>
In article <6lppul$ma4$8@csnews.cs.colorado.edu>,
tchrist@mox.perl.com says...
> Keep in mind that last time I checked, American work weeks did not
> follow that. Perhaps this has changed. I got out of the work business
> long ago. :-)
As far as I know, there are two conflicting ways of determining
the first 'work' week of the year:
* the pragmatic way:
the week containing the 1st Monday of that calendar year.
* the ISO way, in which
* 'Week' is defined as Monday-Sunday
* The first week of a calendar year is the first week
containing four (4) days -- this has the implication
of allowing the calendar year to begin as early as
December 29th of the previous calendar year and
as late as January 4th. In other words, the first week
of the ISO year is that Monday-Sunday period containing
the first Thursday of the calendar year.
--
Nicholas Carey
------------------------------
Date: 12 Jun 1998 16:34:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Prob in FAQ: Week of the year
Message-Id: <6lrlbe$jqr$6@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, ncarey@harlequin.com (Nicholas Carey) writes:
: * the pragmatic way:
: * the ISO way, in which
Ironic discrepancy.
--tom
--
"If you only have a nail, you tend to see every hammer as a problem."
--Larry Wall
------------------------------
Date: Fri, 12 Jun 1998 16:22:28 GMT
From: Justin Vallon <vallon@bear.com>
Subject: Re: question on a process mgmt (how to kill a child process without creating zombie)
Message-Id: <x6eu35qmw2t.fsf@pearl.bear.com>
Greg Hersh <ghersh@bbnplanet.com> writes:
> I have a situation where I have to fork multiple child processes but
> if any of those haven't finished in say 10 minutes, kill them.
> Then start the whole thing again, and again, and again ...
>
> A script (Perl 5.004) forks the processes, saves pid of each,
> goes to sleep for 10 minutes, wakes up, then waitpid with WNOHANG
> option and issues kill 9 $pid if return status = 0.
> Unfortunately if child does get killed, this creates a zombie
> processes. After a while I got quite a few of them. Is there any
> way to terminate the child without creating a zombie?
Your child is fine.
I would guess that you use waitpid (looking for a particular child).
Simply, wait for any child WNOHANG. If an 'interesting' child
completes, record that fact "Process xyz completed". If a killed
child completes (one you've signalled), ignore it. That'll clean
up zombies. If wait returns "nothing new", check timeouts, and kill.
I would recommend that you not start another job until the job that
you kill exits. That would prevent you from creating runaway jobs
(suppose NFS is down, kill -9 is blocked).
Also, if the kill -9 is not effective, re-kill after a timeout.
So:
Upon startup, set the process timeout.
while (things still running)
wait(WNOHANG):
No children: Check timeouts, kill+reset timeout, sleep a
little.
Good exit: Process successful. Mark job completed.
Bad exit: Did we kill it (Signal 9?), restart it.
Otherwise, report script failed.
That's a little more bulletproof.
For one child:
while (1) {
Start process
while (not exec timeout) { wait; return if success; sleep 10; }
# Kill
while (1) { kill -9 process; sleep 10; wait; last if exited; }
# Cleaned up
# Restart
}
--
-Justin
vallon@bear.com
------------------------------
Date: 12 Jun 1998 16:26:53 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: question on a process mgmt (how to kill a child process without creating zombie)
Message-Id: <6lrksd$jqr$5@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Justin Vallon <vallon@bear.com> writes:
:(suppose NFS is down, kill -9 is blocked).
I disbelieve, strenuously--as, I would imagine, does your kernel.
:Also, if the kill -9 is not effective, re-kill after a timeout.
Even if it *were* blocked, which I continue to doubt, as it
is against the rules, blocking is not ignoring. And since
signalling is an idempotent operation, repeating it won't help.
--tom
--
X-Windows: More than enough rope.
--Jamie Zawinski
------------------------------
Date: 12 Jun 1998 15:56:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Subs and References and implicit arguments
Message-Id: <6lrj45$m81@news-central.tiac.net>
In article <qylg1hafzhl.fsf@ubu.enst.fr>,
Akim Demaille <demaille@inf.enst.fr> wrote:
>How do I program a function which transparently modifies its argument,
>and is able, when no argument is given, to apply on $_?
>
You probably don't want to use prototypes here
This might not be the best way to do it, but might be acceptable:
#!/usr/local/bin/perl -w
sub clean {
@_ or return &clean ($_);
for (@_) {
s/^\s+//;
s/\s+$//;
}
return; # guarantee no values returned
}
$foo = " lsk fl; l; sdfk; ";
clean $foo;
print "($foo)\n";
$_ = " jdklsjfg s ";
clean;
print "($_)\n";
__END__
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 12 Jun 1998 18:15:57 +0200
From: Akim Demaille <demaille@inf.enst.fr>
Subject: Re: Subs and References and implicit arguments
Message-Id: <qylvhq6egua.fsf@ubu.enst.fr>
>>>>> "Akim" == Akim Demaille <demaille@inf.enst.fr> writes:
Akim> Hi!
Akim> How do I program a function which transparently modifies its
Akim> argument, and is able, when no argument is given, to apply on
Akim> $_?
I have received several propositions. Thanks to them!
#! /usr/local/bin/perl -w
#
# From Guy Decoux <decoux@moulon.inra.fr>
#
sub clean1 {
for (@_?@_:($_)) {
s/\s+/ /g;
s/^\s//;
s/\s$//;
}
}
$_ = " 1lsk fl; l; sdfk; ";
clean1;
print "($_)\n";
$foo = " 2lsk fl; l; sdfk; ";
clean1 $foo;
print "($foo)\n";
#
# From Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
#
sub clean2
{
my $string=\(shift||$_);
for($$string)
{
s/\s+/ /g;
s/^\s//;
s/\s$//;
}
}
$_ = " 1lsk fl; l; sdfk; ";
clean2;
print "($_)\n";
$foo = " 2lsk fl; l; sdfk; ";
clean2 $foo;
print "($foo)\n";
#
# From Mike Stok <mike@stok.co.uk>
#
sub clean3 {
@_ or return &clean3 ($_);
for (@_) {
s/\s+/ /g;
s/^\s+//;
s/\s+$//;
}
return; # guarantee no values returned
}
$_ = " 1lsk fl; l; sdfk; ";
clean3;
print "($_)\n";
$foo = " 2lsk fl; l; sdfk; ";
clean3 $foo;
print "($foo)\n";
___END___
Akim
--
P-mail: Akim Demaille, 107 rue Bobillot, F-75013 Paris, France
E-mail: demaille@inf.enst.fr
V-mail: +33 1 45 81 78 68
------------------------------
Date: 12 Jun 1998 16:35:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Subs and References and implicit arguments
Message-Id: <6lrlcr$m81@news-central.tiac.net>
In article <6lrj45$m81@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:
>In article <qylg1hafzhl.fsf@ubu.enst.fr>,
>Akim Demaille <demaille@inf.enst.fr> wrote:
>
>>How do I program a function which transparently modifies its argument,
>>and is able, when no argument is given, to apply on $_?
>>
>
>You probably don't want to use prototypes here
>
>This might not be the best way to do it, but might be acceptable:
>
>#!/usr/local/bin/perl -w
>
>sub clean {
> @_ or return &clean ($_);
>
> for (@_) {
> s/^\s+//;
> s/\s+$//;
> }
>
> return; # guarantee no values returned
>}
Sorry I forgot the s/\s+/ /g; which might be better after trimming the
leading & trailing spaces, and this will operate on a whole list of
supplied parameters rather than just one. If you just want to do the
first element of @_ you can put a last at the bottom of the loop.
I'm sure there's some cunning way of making $_[0] an alias for $_ if @_ is
empty which would save a subroutine call but this seems easier to me.
If you really want prototypes then I suppose you can end up with:
sub clean (;$) {
@_ or return &clean ($_);
for (@_) {
s/^\s+//;
s/\s+$//;
s/\s+/ /g;
}
return;
}
Be aware that the prototype is a runtime rather than a compile time thing,
with it this sequence:
$foo = " lsk fl; l; sdfk; ";
$bar = " Mike Stok ";
@list = ($foo, $bar);
clean $foo;
print "($foo) ($bar)\n";
clean @list;
print ">@list<\n";
produces:
(lsk fl; l; sdfk;) ( Mike Stok )
> lsk fl; l; sdfk; Mike Stok <
without the prototype it produces:
(lsk fl; l; sdfk;) ( Mike Stok )
>lsk fl; l; sdfk; Mike Stok<
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
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 2855
**************************************