[16932] in Perl-Users-Digest
Perl-Users Digest, Issue: 4344 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 16 21:10:21 2000
Date: Sat, 16 Sep 2000 18:10:12 -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: <969153012-v9-i4344@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 16 Sep 2000 Volume: 9 Number: 4344
Today's topics:
Re: self writing program <anmcguire@ce.mediaone.net>
Re: self writing program (Gwyn Judd)
Re: setproctitle analog in Perl <philipg@atl.mediaone.net>
Re: Shortest code for Fibonacci? <anmcguire@ce.mediaone.net>
Re: Shortest code for Fibonacci? (Abigail)
Re: sprintf() rounding problem (Mike Stok)
Re: sprintf() rounding problem <iltzu@sci.invalid>
Tweaking Cookies <mike@sas-inc.com>
Re: using filehandles in strict mode (Tom Christiansen)
Re: Where can we get the PDK? <bwalton@rochester.rr.com>
Re: Which environment var can I use? <christopher_j@uswest.net>
which the best scripting language? <lucisferre@email.com>
Re: which the best scripting language? <nospam@david-steuber.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 16 Sep 2000 16:56:09 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: self writing program
Message-Id: <Pine.LNX.4.21.0009161653160.26633-100000@hawk.ce.mediaone.net>
On Sat, 16 Sep 2000, Tony Bowden quoth:
TB> Marcel Grunauer <marcel@codewerk.com> wrote:
TB> >>I wanted to write a program in perl that when invoked
TB> >>prints out a copy of exactly itself.
TB>
TB> > open+0;print<0>
TB>
TB> I know it wasn't in the OP's spec, but any time I've encountered
TB> this problem it was either prohibited, or considered bad form,
TB> for the program to examine its own source ...
I may be a little slow here (forgive me), but if a program
can not examine itself, or at least replicate itself, then how can
it print itself? Meaning, how would it know what to print?
anm
--
print map y="= = && $_ => <"\bJust> =>
=> <"Another> =>
=> <"Perl> =>
=> <"Hacker\n> =>
------------------------------
Date: Sun, 17 Sep 2000 00:48:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: self writing program
Message-Id: <slrn8s856j.3ij.tjla@thislove.dyndns.org>
I was shocked! How could Andrew N. McGuire <anmcguire@ce.mediaone.net>
say such a terrible thing:
>On Sat, 16 Sep 2000, Tony Bowden quoth:
>
>TB> Marcel Grunauer <marcel@codewerk.com> wrote:
>TB> >>I wanted to write a program in perl that when invoked
>TB> >>prints out a copy of exactly itself.
>TB>
>TB> > open+0;print<0>
>TB>
>TB> I know it wasn't in the OP's spec, but any time I've encountered
>TB> this problem it was either prohibited, or considered bad form,
>TB> for the program to examine its own source ...
>
>I may be a little slow here (forgive me), but if a program
>can not examine itself, or at least replicate itself, then how can
>it print itself? Meaning, how would it know what to print?
http://www.plover.com/~mjd/perl/quine.html
http://www.mines.edu/students/b/bolmstea/quines/#perl
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Flight by machines heavier than air is unpractical and insignificant,
if not utterly impossible.
-Simon Newcomb 1902, eighteen months before Kitty Hawk
------------------------------
Date: Sat, 16 Sep 2000 19:57:48 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: setproctitle analog in Perl
Message-Id: <0hQw5.3717$jC4.1034163@typhoon.southeast.rr.com>
Andrew Zhilenko <andrew@nextra.cz> wrote in message
news:39C37CBA.FEDE10A6@nextra.cz...
> Hello!
>
> How can change the name of my perl program (shown by ps)?
> I want for example to get rid of "/usr/bin/perl" there.
> In the BSD-flavored unixes exists setproctitle function,
> but I do not know analog of it in SysV.
Try: $0 = 'new proc title';
From perldoc perlvar:
$0 Contains the name of the program being executed.
On some operating systems assigning to `$0'
modifies the argument area that the ps program
sees. This is more useful as a way of indicating
the current program state than it is for hiding
the program you're running. (Mnemonic: same as sh
and ksh.)
hth,
p
------------------------------
Date: Sat, 16 Sep 2000 16:26:10 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <Pine.LNX.4.21.0009161621020.26633-100000@hawk.ce.mediaone.net>
On Sat, 16 Sep 2000, Jeff Pinyan quoth:
JP> On Sep 16, Tramm Hudson said:
JP>
JP> >PS: On a related note, I can factor primes in constant time.
JP>
JP> A damn long time, I assume. ;)
JP>
Huh? :-) If you already know a number is prime, it only has
two factors, itself and one. Of course testing for primality
for any number n takes an increasingly long period of time as
n approaches infinity.
anm
--
print map y="= = && $_ => <"\bJust> =>
=> <"Another> =>
=> <"Perl> =>
=> <"Hacker\n> =>
------------------------------
Date: 16 Sep 2000 21:40:31 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Shortest code for Fibonacci?
Message-Id: <slrn8s7q4c.4mc.abigail@alexandra.foad.org>
Andrew N. McGuire (anmcguire@ce.mediaone.net) wrote on MMDLXXIII
September MCMXCIII in <URL:news:Pine.LNX.4.21.0009161621020.26633-100000@hawk.ce.mediaone.net>:
`' On Sat, 16 Sep 2000, Jeff Pinyan quoth:
`'
`' JP> On Sep 16, Tramm Hudson said:
`' JP>
`' JP> >PS: On a related note, I can factor primes in constant time.
`' JP>
`' JP> A damn long time, I assume. ;)
`' JP>
`'
`' Huh? :-) If you already know a number is prime, it only has
`' two factors, itself and one. Of course testing for primality
`' for any number n takes an increasingly long period of time as
`' n approaches infinity.
Actually, factorizing a prime P takes O (log P) time, as it takes log
P bits write down P, and your program first has to read P, then write
1 and P. ;-)
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: Sat, 16 Sep 2000 18:28:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: sprintf() rounding problem
Message-Id: <aZOw5.2283$WK6.29257@typhoon.austin.rr.com>
In article <slrn8s4s7k.4mc.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
>I'm sure that if you buy something in the store that as 17.5% value tax,
>you don't end up paying an amount that isn't expressable as an integer
>number of pennies.
>
>Why don't you apply the same rules?
In the good old days in England fractional pennies weren't un-heard of
(... of course in those days a penny was worth something, so a farthing
was useful...) and even after the dumbing down of the currency at the
beginning of the '70s there were 1/2 new penny coins, and old sixpenny
pieces could still be used (worth 2 1/2 "new pence").
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ |
GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA
------------------------------
Date: 16 Sep 2000 22:04:13 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: sprintf() rounding problem
Message-Id: <969141446.23551@itz.pp.sci.fi>
In article <jjk3sss9589r5tc7viaqq5qh04g8cs5me8@4ax.com>, Bart Lateur wrote:
>David Hugh-Jones wrote:
>>
>>$tax=17.5;
>>$value=57; # (for example )
>>$value+=$value*$tax*0.01; # tax is a percentage
>>$value = sprintf(%.2f,$value); # to convert $value to the nearest penny
>>
>>My problem is that sprintf doesn't round the numbers correctly. E.g. for
>>this instance, $value is 66.975 after line 3. This should round to 66.98,
>>but in fact the fourth line outputs 66.97.
>
>Yes... that's this annoying "round halves to nearest even" behaviour.
>Statistically, it's "nice", but boy I sure hate the guts of it.
No it's not. Read the original post. He's complaining of sprintf()
rounding down to an _odd_ digit.
The problem is that his value is _slightly less_ than 66.975, so any
sensible rounding rule is going to give 66.97.
Working in integral cents is one solution. Math::Fraction is another.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Sat, 16 Sep 2000 19:21:47 -0400
From: "Michael Satkevich" <mike@sas-inc.com>
Subject: Tweaking Cookies
Message-Id: <8q0gal$v6o$1@murdoch.harvard.net>
I sent a cookie to my PC using the cookie method of a CGI object.
When I checked my hard drive the cookie file was named "mike@cgi-bin".
How do I make the file name refer to the site from whence it originated?
I see other cookies named "mike@lycos", etc.
Just curious,
mike
------------------------------
Date: 16 Sep 2000 16:53:41 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: using filehandles in strict mode
Message-Id: <39c3f9f5@cs.colorado.edu>
In article <u9u2bl356z.fsf@wcl-l.bham.ac.uk>, <nobull@mail.com> wrote:
>> my $fh = *STDIN;
>Huh? I don't get it. Doesn't that make $fh a symbolic reference?
>Evidently not. So just what is the thing in $fh in this case?
A glob.
>my $fh = *STDIN; print ref $fh;
>
>But GLOB if I do:
>
>my $fh = \*STDIN; print ref $fh;
>
>What is the difference between the two cases?
One is a reference. One is not.
>Why does ref() tell me that a scalar containing a typeglob is a plain
>scalar?
Because a typeglob is not a reference to a typeglob.
However, they can in most cases be used interchangeably.
--tom
------------------------------
Date: Sat, 16 Sep 2000 21:08:25 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Where can we get the PDK?
Message-Id: <39C3E163.76AE2420@rochester.rr.com>
i0519@my-deja.com wrote:
>
> As title.
...
http://www.activestate.com
--
Bob Walton
------------------------------
Date: Sat, 16 Sep 2000 11:30:37 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Which environment var can I use?
Message-Id: <i%Ow5.210$yX3.135349@news.uswest.net>
<bill@bitco.com> wrote:
> I have two domain names pointing to the same IP address. It doesn't
> matter which one I type in from my browser, I will get the same index
> page. I would like to set up a perl redirect script that my index page
> will call. This redirect needs to find out which domain name was used
> to call the script so it can then redirect to the correct page for that
> domain name.
>
> Does anybody know which environment var I could use to deturmine which
> domain name was used to get to the IP address? If somebody has already
> done somthing like this could you tell me how you did it? Thank You
Why aren't you using virtual hosting with your web server?
It works a _lot_ better than any CGI hack.
------------------------------
Date: Sun, 17 Sep 2000 01:09:39 +0700
From: "Lucisferre" <lucisferre@email.com>
Subject: which the best scripting language?
Message-Id: <39c4847e.0@news.cbn.net.id>
You think which is the best scripting language? Perl or TCL? What is your
best scripting language?
Thanx
rgd. lf
------------------------------
Date: Sun, 17 Sep 2000 01:01:01 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: which the best scripting language?
Message-Id: <m3snqz3k8r.fsf@solo.david-steuber.com>
"Lucisferre" <lucisferre@email.com> writes:
' You think which is the best scripting language? Perl or TCL? What is your
' best scripting language?
Is this a troll?
I can do more with Perl than I can with TCL and Python. However, that
is because I know Perl better and CPAN is very comprehensive indeed.
I don't care for Python's block syntax structure. I have no
complaints about TCL, but I hardly know the language. It is supposed
to be easier to embed in an application as a scripting language.
Easier doesn't mean better though.
One thing is for sure. With either Perl or Tcl you will be able to
get a lot of support. I think more support is available for Perl, but
that is purely a subjective impression.
--
David Steuber | Perl apprentice, Apache/mod_perl user, and
NRA Member | general Internet web wannabe.
ICQ: 91465842
It's time to be free: http://www.harrybrowne2000.org
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4344
**************************************