[13871] in Perl-Users-Digest
Perl-Users Digest, Issue: 1281 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 4 15:15:31 1999
Date: Thu, 4 Nov 1999 12:15:23 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941746523-v9-i1281@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 4 Nov 1999 Volume: 9 Number: 1281
Today's topics:
Re: Round off a number raju_k@iname.com
Re: Round off a number <splazony@entigo.com>
Re: Round off a number <debot@xs4all.nl>
Re: Round off a number <camerond@mail.uca.edu>
Special Problem <debot@xs4all.nl>
Re: What does HAND mean? (Bart Lateur)
Re: Who is worse: Cops or Criminals <pjbrons@gironet.nl>
Re: Why am I getting an undefined subroutine error? <aqumsieh@matrox.com>
Re: Why am I getting an undefined subroutine error? (Kragen Sitaker)
Re: Why am I getting an undefined subroutine error? (Bart Lateur)
Re: Year 2000 date problem (Michel Dalle)
Re: Year 2000 date problem (Craig Berry)
Re: Year 2000 date problem (Craig Berry)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 04 Nov 1999 17:10:24 GMT
From: raju_k@iname.com
Subject: Re: Round off a number
Message-Id: <7vselt$19v$1@nnrp1.deja.com>
sub
round {
my($num, $places) = @_;
my $tmpl = "%.${places}f";
return sprintf($tmpl, $num);
}
a call like:
print round(3.1415926, 3), "\n";
will display:
3.142
--raju
In article <38221DE8.167E@u-picardie.fr>,
Francois Dupradeau <fyd@u-picardie.fr> wrote:
> Dear All,
>
> Is there a function in Perl to round off the 2nd or the third (or the
> 5th, etc...) number after the decimal point of a number ?
> ex:
> 3.123456789 => 3.123
>
> Thanks
> Regards
> Francois
>
> --
> Francois Dupradeau
> ------------
> Faculte de Pharmacie
> 1, rue des Louvels
> 80037 Amiens Cedex
> France
> ------------
> Tel 33 (0)3 22 82 74 94
> Fax 33 (0)3 22 82 74 69
> Email fyd@u-picardie.fr
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 04 Nov 1999 12:41:10 -0500
From: steve plazony <splazony@entigo.com>
Subject: Re: Round off a number
Message-Id: <3821C536.6A9375A8@entigo.com>
using the round sub below, can anyone explain this:
print round(113.1415, 3), "\n";
- displays 113.141
and
print round(113.14151, 3), "\n";
- displays 113.142
i have read articles about Perl rounding differently
from machine to machine.
here are the machine specs that i am running on:
Machine hardware: sun4u
OS version: 5.6
Processor type: sparc
Hardware: SUNW,Ultra-1
raju_k@iname.com wrote:
> sub
> round {
> my($num, $places) = @_;
> my $tmpl = "%.${places}f";
> return sprintf($tmpl, $num);
> }
>
> a call like:
>
> print round(3.1415926, 3), "\n";
>
> will display:
>
> 3.142
>
> --raju
>
> In article <38221DE8.167E@u-picardie.fr>,
> Francois Dupradeau <fyd@u-picardie.fr> wrote:
> > Dear All,
> >
> > Is there a function in Perl to round off the 2nd or the third (or the
> > 5th, etc...) number after the decimal point of a number ?
> > ex:
> > 3.123456789 => 3.123
> >
> > Thanks
> > Regards
> > Francois
> >
> > --
> > Francois Dupradeau
> > ------------
> > Faculte de Pharmacie
> > 1, rue des Louvels
> > 80037 Amiens Cedex
> > France
> > ------------
> > Tel 33 (0)3 22 82 74 94
> > Fax 33 (0)3 22 82 74 69
> > Email fyd@u-picardie.fr
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Thu, 04 Nov 1999 19:42:56 +0100
From: Frank de Bot <debot@xs4all.nl>
Subject: Re: Round off a number
Message-Id: <3821D3B0.3311561A@xs4all.nl>
Yes, I do:
$string = 1.234567890;
$round1 = int($string * 1 +0.5) / 1; # 1
$round2 = int($string * 10 + 0.5) / 10; # 1.23
$round3 = int($string * 100 + 0.5) / 100; # 1.235
$round4 = int($string * 1000 +0.5) / 1000; # 1.246
$round5 = int($string * 10000 + 0.5) / 10000; # 1.2346
$round6 = int($string * 100000 + 0.5) / 100000; # 1.23457
And so on. You can see it rounds up and down. ( Next decimal = 5 rounds
up. Else down)
Francois Dupradeau wrote:
> Dear All,
>
> Is there a function in Perl to round off the 2nd or the third (or the
> 5th, etc...) number after the decimal point of a number ?
> ex:
> 3.123456789 => 3.123
>
> Thanks
> Regards
> Francois
>
> --
> Francois Dupradeau
> ------------
> Faculte de Pharmacie
> 1, rue des Louvels
> 80037 Amiens Cedex
> France
> ------------
> Tel 33 (0)3 22 82 74 94
> Fax 33 (0)3 22 82 74 69
> Email fyd@u-picardie.fr
------------------------------
Date: Thu, 04 Nov 1999 13:20:33 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Round off a number
Message-Id: <3821DC81.2329B5EA@mail.uca.edu>
steve plazony wrote:
>
> using the round sub below, can anyone explain this:
>
> print round(113.1415, 3), "\n";
> - displays 113.141
>
> and
>
> print round(113.14151, 3), "\n";
> - displays 113.142
>
perlfaq4
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Thu, 04 Nov 1999 20:02:27 +0100
From: Frank de Bot <debot@xs4all.nl>
Subject: Special Problem
Message-Id: <3821D842.92FBC620@xs4all.nl>
I'll try to explain this as good as possible.
I've a perl script ( test.pl ) with some HTML anchors. is there a way to
create a HTTP_REFERER that isn't indentical to the one the browser wants
to give.
So I click on a link from this page: http://127.0.0.1/test.pl and I'll
'land' at otherfile.pl . If I ask for the referer at otherfile.pl I want
to return to something other.
Is this possible?
Any help will be apperciated.
Frank de Bot
------------------------------
Date: Thu, 04 Nov 1999 17:55:13 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: What does HAND mean?
Message-Id: <3827c821.3662728@news.skynet.be>
Abigail wrote:
>&& What does HAND mean? I am not familiar with it.
>
>
>It's the piece of meat that connects your fingers to your wrist.
>
Only meat (er, "flesh")? Yuck.
--
Bart.
------------------------------
Date: Thu, 4 Nov 1999 19:02:33 +0100
From: "PJ Brons" <pjbrons@gironet.nl>
Subject: Re: Who is worse: Cops or Criminals
Message-Id: <941738579.513880@samba.news.big-orange.net>
What is Rev. standing for????????????????????
Rev. Meowatilla Al' Rashad heeft geschreven in bericht
<7vqq5m$8p0$2@nntpd.databasix.com>...
>In <3820F510.46FE@night.com>, Jamin,CISOL wrote:
>> JBP615 wrote:
>> >
>I prove whatever half-facts I want, fuckhead. But did I tell you you could
get
>your tongue out of my asshole and speak? GET BACK TO WORK YOU LITTLE SHIT.
>
>This is your last warning.
------------------------------
Date: Thu, 4 Nov 1999 10:30:42 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Why am I getting an undefined subroutine error?
Message-Id: <x3yn1sus28u.fsf@tigre.matrox.com>
kragen@dnaco.net (Kragen Sitaker) writes:
> In article <x3yvh7jrv2q.fsf@tigre.matrox.com>,
> Ala Qumsieh <aqumsieh@matrox.com> wrote:
> >"Peter Steele" <psteele@opticalnetworks.com> writes:
> >> I have Perl installed on my Windows NT system and am trying to make use of
> >> some of packages that are part of the distribution. I tried a very simple
> >> script:
> >>
> >> use Net::ping;
> >> print "alive" if pingecho('localhost', 10);
> >>
> >> but when I run this I get the error
> >>
> >> Undefined subroutine &main::pingecho called at - line 2
> >>
> >> Can anyone explain what is causing this error?
> >
> >You either have a typo in your little snippet above, or you're lying
> >to us.
>
> Or you're using a case-insensitive filesystem; given that you're on
> Windows NT, that's probably the case.
Of course it is. The original poster clearly indicates that he's on a
WinNT system.
> >The use() statements get executed in compile time. The correct module
> >name in Net::Ping. Perl is case-sensitive, even on winblows.
>
> Perl is case-sensitive for package method lookup, but not filename
> lookup. But if, on Unix, I have a Net/ping.pm that says:
> package Net::Ping;
> sub pingecho { 'foo' }
> 1;
>
> . . . I can happily say
> use Net::ping;
> and not know that anything is wrong.
Hmm. I don't get it. Maybe I am confused, but here's what actually
happens:
% cd myNet
% cat Ping.pm
package myNet::Ping;
1;
% cd ..
% perl -MmyNet::Ping -e 1
% perl -MmyNet::ping -e 1
Can't locate myNet/ping.pm in @INC (@INC contains:
/opt/perl-5.005_03/lib/5.00503/sun4-solaris
/opt/perl-5.005_03/lib/5.00503
/opt/perl-5.005_03/lib/site_perl/5.005/sun4-solaris
/opt/perl-5.005_03/lib/site_perl/5.005 .).
BEGIN failed--compilation aborted.
Now, let's try to rename Ping.pm to ping.pm and see:
% cd myNet
% mv Ping.pm ping.pm
% cd ..
% perl -MmyNet::Ping -e 1
Can't locate myNet/Ping.pm in @INC (@INC contains:
/opt/perl-5.005_03/lib/5.00503/sun4-solaris
/opt/perl-5.005_03/lib/5.00503
/opt/perl-5.005_03/lib/site_perl/5.005/sun4-solaris
/opt/perl-5.005_03/lib/site_perl/5.005 .).
BEGIN failed--compilation aborted.
% perl -MmyNet::ping -e 1
%
So, if I understand correctly, it does matter whether the file is
Net::Ping or Net::ping (on a real file-system at least. I didn't test
on winblows). But it doesn't matter whether the package
declaration within the file is Net::Ping or Net::ping.
I don't like that. Does this mean that my FOO::Bar::* variables will
clash with my FOO::bar::* variables?
> >Unless you have a module called Net::ping hidden somewhere in your
> >@INC directories, your program should have never compiled, and you
> >would've never gotten the error, which happens at run time.
>
> As far as perl can tell (at least by attempting to open() it, which is
> what it does on Unix and, I assume, on Windows too), it *is* called
> Net/ping.pm.
>
> This guy is the second one today to report this problem, so I suspect
> he's not lying.
I hope it came across everyone's mind that I was joking when I said
that. Accusing him of lying wasn't my intention, and I simply thought
that he didn't cut and paste his code.
--Ala
------------------------------
Date: Thu, 04 Nov 1999 17:57:38 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Why am I getting an undefined subroutine error?
Message-Id: <mOjU3.27888$23.1474572@typ11.nn.bcandid.com>
In article <x3yn1sus28u.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>Hmm. I don't get it. Maybe I am confused, but here's what actually
>happens:
Method lookup is case-sensitive in Perl, just like always. But
filename lookup depends on the OS. So use Net::ping will find the
right file, but it won't find the import method.
Perl will happily do whatever is in the file, whether it is in the
package specified by the filename or not. This is sometimes thought of
as a good thing, as it allows you to put many private classes in a
file.
>So, if I understand correctly, it does matter whether the file is
>Net::Ping or Net::ping (on a real file-system at least. I didn't test
>on winblows). But it doesn't matter whether the package
>declaration within the file is Net::Ping or Net::ping.
No. It doesn't matter whether the package declaration within the file
is Net::Ping or Sousa::Fluegelhorn. Until you try to call routines or
methods from the package, at which point it doesn't matter what the
filename was.
So what's happening is that he has the wrong package name, but perl
finds the file anyway because the fs is case-insensitive, but fails to
import the desired routines because there is no Net::ping package in
the file he included, just a Net::Ping package.
>I hope it came across everyone's mind that I was joking when I said
>that. Accusing him of lying wasn't my intention, and I simply thought
>that he didn't cut and paste his code.
I hope so too. :)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Thu, 04 Nov 1999 17:56:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why am I getting an undefined subroutine error?
Message-Id: <3828c8a0.3789989@news.skynet.be>
David Cassell wrote:
>Even on win32 systems, Perl is case-sensitive. The module
>is named Net::Ping , not Net::ping . Perl couldn't find the
>module because of the case error.
Well, it COULD. It found the file. It didn't import anything, because of
the case error, and Net::ping::import wasn't found. I would think.
--
Bart.
------------------------------
Date: Thu, 04 Nov 1999 18:28:31 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Year 2000 date problem
Message-Id: <7vsjie$olu$1@news.mch.sbs.de>
In article <rEfU3.12$Go3.1152@vic.nntp.telstra.net>, "Wyzelli" <wyzelli@yahoo.com> wrote:
[snip]
>You can expect an increasing number of these over the next few months! My
>advice is to take holidays now.. for about 16 weeks.
And you think we have troubles ? Here's what Microsoft has
to say about Y2K problems with JScript :
| What are the Year 2000 Bug problems with JScript?
|
| It is very easy to write code which will fail in the year 2000
| in JScript due to a poor design decision in the Date object.
| <snip>
You can read the rest of the story at :
<http://msdn.microsoft.com/scripting/default.
htm?/scripting/jscript/techinfo/jsfaq.htm>
Michel.
------------------------------
Date: Thu, 04 Nov 1999 19:20:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Year 2000 date problem
Message-Id: <s23n346u24245@corp.supernews.com>
Kragen Sitaker (kragen@dnaco.net) wrote:
: In article <s21bfjog24218@corp.supernews.com>,
: Craig Berry <cberry@cinenet.net> wrote:
: > I mean, who would start using a tool without understanding it?
:
: I have never understood a tool without using it first. I do, however,
: generally read the manual.
Obviously, 'understanding' is a continuum. My meaning was at the "which
end of this thing do I hold" level of understanding, corresponding to a
preliminary pass through the manual.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Thu, 04 Nov 1999 19:22:21 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Year 2000 date problem
Message-Id: <s23n7d3u24283@corp.supernews.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: In article <s21bfjog24218@corp.supernews.com> on Wed, 03 Nov 1999
: 21:49:39 GMT, Craig Berry <cberry@cinenet.net> says...
: > ... using a subrange to do the list slice, we derive the more concise
: >
: > ($sec, $min, $hour, $mday, $mon, $year, $wday) = (localtime)[0..6];
:
: Using the assignment to do the list slice, we derive the more concise
:
: ($sec, $min, $hour, $mday, $mon, $year, $wday) = localtime;
Um, well, yeah, there is that, of course. :) (I usually slice out
non-contiguous, non-zero-based members of the localtime return list, so
this simplification eluded me. Nice catch.)
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
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 1281
**************************************