[19861] in Perl-Users-Digest
Perl-Users Digest, Issue: 2056 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 2 18:06:21 2001
Date: Fri, 2 Nov 2001 15:05:07 -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: <1004742306-v10-i2056@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 2 Nov 2001 Volume: 10 Number: 2056
Today's topics:
[OT] help with simple script (John J. Trammell)
Re: [OT] help with simple script (Jason Kohles)
Re: [OT] help with simple script (John J. Trammell)
Re: apostrophe character in text boxes and mysql <sommar@algonet.se>
CGI.pm and File Upload Problem <pottschmidtr@appstate.edu>
DB module to store references? <prlawrence@lehigh.edu>
Re: desperate: perl scripts called from init.d/... scri <Robert.Lopez@abq.sc.philips.com>
Re: desperate: perl scripts called from init.d/... scri <Robert.Lopez@abq.sc.philips.com>
Re: desperate: perl scripts called from init.d/... scri <stuart@otenet.gr>
Re: help with simple script <tdupuis@omafra.gov.on.ca>
Re: How to: If (exactstring) then.. [learning Perl] <emelindjo@hotmail.com>
Re: One liners vs. verbose code <darkon@one.net>
Re: One liners vs. verbose code (Tad McClellan)
Re: One liners vs. verbose code <darkon@one.net>
Perl semi-newbie looking to split HTML into XSL & XML (Gene Smilgiewicz)
Re: pervent multiple instances of a server (Richard J. Rauenzahn)
Re: Q: exclusive bind() on Unix Domain Socket? <uwe@richard-schneider.de>
Re: Q: exclusive bind() on Unix Domain Socket? (Logan Shaw)
Re: Taint problem with BEGIN block (BUCK NAKED1)
Re: Unsigned 8 bit math (addition and subtraction) <stuart@otenet.gr>
Re: Unsigned 8 bit math (addition and subtraction) <iltzu@sci.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 2 Nov 2001 14:08:25 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: [OT] help with simple script
Message-Id: <slrn9u5v9r.h12.trammell@haqq.el-swifto.com>
On Fri, 02 Nov 2001 14:39:49 -0500, Terry <tdupuis@omafra.gov.on.ca> wrote:
> X-No-Archive: Yes
You realize that this is not in your message's header, and
needs to be, right?
------------------------------
Date: 2 Nov 2001 20:27:26 GMT
From: usenet@jasonkohles.com (Jason Kohles)
Subject: Re: [OT] help with simple script
Message-Id: <slrn9u608t.dog.usenet@poseidon.mediabang.com>
On Fri, 2 Nov 2001 14:08:25 -0600, John J. Trammell wrote:
>On Fri, 02 Nov 2001 14:39:49 -0500, Terry <tdupuis@omafra.gov.on.ca> wrote:
>> X-No-Archive: Yes
>
>You realize that this is not in your message's header, and
>needs to be, right?
>
Most of the big archiving sites will honor it as the first line of the message,
in case your newsreader doesn't let you modify the headers.
--
Jason S Kohles A witty saying proves nothing.
email@jasonkohles.com -- Voltaire (1694 - 1778)
http://www.jasonkohles.com/
------------------------------
Date: Fri, 2 Nov 2001 15:55:09 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: [OT] help with simple script
Message-Id: <slrn9u65i0.i2l.trammell@haqq.el-swifto.com>
On 2 Nov 2001 20:27:26 GMT, Jason Kohles <usenet@jasonkohles.com> wrote:
> On Fri, 2 Nov 2001 14:08:25 -0600, John J. Trammell wrote:
> >On Fri, 02 Nov 2001 14:39:49 -0500, Terry <tdupuis@omafra.gov.on.ca> wrote:
> >> X-No-Archive: Yes
> >
> >You realize that this is not in your message's header, and
> >needs to be, right?
> >
> Most of the big archiving sites will honor it as the first line of the message,
> in case your newsreader doesn't let you modify the headers.
>
Damned if I don't learn something new every day. :-)
--
If you don't look at the fnord, it can't get you.
------------------------------
Date: Fri, 2 Nov 2001 22:59:02 +0000 (UTC)
From: Erland Sommarskog <sommar@algonet.se>
Subject: Re: apostrophe character in text boxes and mysql
Message-Id: <Xns914DF3F64A0DAYazorman@127.0.0.1>
hugo (hugo@fractalgraphics.com.au) writes:
> How can I have people include the ' character without it causing
> problems for mysql?
Stop using mysql and start using MS SQL Server. I mean you are
already posting messages to the SQL Server newsgroups, so you're
already halfway there.
--
Erland Sommarskog, Abaris AB
sommar@algonet.se
SQL Server MVP
------------------------------
Date: Fri, 02 Nov 2001 14:33:02 -0500
From: Robert Pottschmidt <pottschmidtr@appstate.edu>
Subject: CGI.pm and File Upload Problem
Message-Id: <3BE2F4EE.C3E58E89@appstate.edu>
Hello Out There
My problem is as follows:
I am having problems upload files using a html push, the script
works find on one of my servers running an older version of perl and
CGI.pm. I get the file name fine, but I do not get the file's data.
The server that has the problem is running perl 5.6.1 and CGI.pm 2.77
Here is my code:
HTML PAGE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form action="cgi-bin/test.pl" enctype="multipart/form-data"
method="post"><inpu
t type="File" name="test"><input type="submit"></form>
</body>
</html>
PERL SCRIPT
#!/usr/bin/perl
use diagnostics;
use CGI;
use Mysql;
my $query = new CGI;
print $query->header("text/html");
$test = $query->param("test");
print $test;
while(my $bytesread = read($test, my $buffer, 1024)){
print $buffer;
}
exit;
Thanks alot
RCP
--
I been rong before
+----------------------------------------------------------------------+
Robert C Pottschmidt Appalachian State University
Internet Applications Developer University Hall
Appalachian Regional Development Institute P.O. Box 32131
Email: pottschmidtr@appstate.edu Boone, NC 28608-2131
Phone: (828) 262-6553 Fax: (828) 262-6553
+----------------------------------------------------------------------+
------------------------------
Date: Fri, 2 Nov 2001 14:55:54 -0500
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: DB module to store references?
Message-Id: <9rutov$kr6@fidoii.CC.Lehigh.EDU>
Hello,
I need to sort a largish file of individual reports; last time I used a hash
to do it. This time around the file was too big -- ran out of memory.
I thought I would use NDBM_File or somesuch to put my hash on the filesystem
instead of in memory, but this and other *DBM_File modules store only flat
scalars. :-(
Before I ask my sysadmin to install Berkley DB (for use with DB_File), can
anyone recommend another module/approach that I might try?
FWIW, the data I need to sort by is not in the file, so I can't use a plain
UNIX utility such as sort. I am noting a unique identifier found on each
report in the file and doing a database lookup to sort those unique
identifiers by related information found in the database. It seemed easiest
to simply store an aref of the report lines in a hash using the unique
identifiers as hash keys.
Thanks!
Phil R Lawrence
------------------------------
Date: 02 Nov 2001 12:23:43 -0700
From: Robert Lopez <Robert.Lopez@abq.sc.philips.com>
Subject: Re: desperate: perl scripts called from init.d/... scripts
Message-Id: <jc6ady5ht8g.fsf@abqb1k.abq.sc.philips.com>
Darren Dunham <ddunham@redwood.taos.com> writes:
> Robert Lopez <Robert.Lopez@abq.sc.philips.com> wrote:
>
> > The scripts work perfectly when run by root manually by running them
> > directly and via the run level links.
> > eg:
> > cd /sbin/init.d; ./script.pl start_msg < -- works
> > cd /sbin/init.d; ./script.pl start < -- works
> > cd /sbin/init.d; ./script.pl stop_msg < -- works
> > cd /sbin/init.d; ./script.pl stop_msg < -- works
> > cd /sbin/rc2.d; ./K96script.pl .... < -- works
> > cd /sbin/rc3.d; ./S96script.pl .... < -- works
>
> Try running it the way rc2 will (on Solaris)...
>
> /sbin/sh /etc/rc2.d/K96script.pl < -- works?
>
> If that doesn't work (it shouldn't), then it won't work at startup.
>
> The script is not executed by rc2. The script is given to sh as an
> argument. If sh doesn't understand it, it won't work.
Ah! Ok.
>
> Solution:
> Write a different script.
>
> /etc/rc2.d/S96script.pl
> #!/bin/sh
> /etc/init.d/someperlscript $1
>
> --
> Darren Dunham ddunham@taos.com
> Unix System Administrator Taos - The SysAdmin Company
> Got some Dr Pepper? San Francisco, CA bay area
> < How are you gentlemen!! Take off every '.SIG'!! >
Thanks!
--
Robert.Lopez@Philips.com
------------------------------
Date: 02 Nov 2001 12:25:55 -0700
From: Robert Lopez <Robert.Lopez@abq.sc.philips.com>
Subject: Re: desperate: perl scripts called from init.d/... scripts
Message-Id: <jc6668tht4s.fsf@abqb1k.abq.sc.philips.com>
"Stuart Gall" <stuart@otenet.gr> writes:
> > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& >
> /logs/dba/cfg21 2>&1
> >
> > HP support rep thinks the problem is the use of perl.
> >
> > Any ideas?
>
> look at /sbin/rc2 to see what, if anything, wired is going on?
I do not understand this at all. Do you mean /sbin/rc2.d?
By "wired" do you mean the soft-links?
>
>
> --
>
> Stuart Gall
> ------------------------------------------------
> This message is not provable.
>
--
Robert.Lopez@Philips.com
------------------------------
Date: Fri, 2 Nov 2001 23:51:52 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: desperate: perl scripts called from init.d/... scripts
Message-Id: <9rv8op$eja$1@usenet.otenet.gr>
"Robert Lopez" <Robert.Lopez@abq.sc.philips.com> wrote in message
news:jc6668tht4s.fsf@abqb1k.abq.sc.philips.com...
> "Stuart Gall" <stuart@otenet.gr> writes:
>
> > > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& >
> > /logs/dba/cfg21 2>&1
> > >
> > > HP support rep thinks the problem is the use of perl.
> > >
> > > Any ideas?
> >
> > look at /sbin/rc2 to see what, if anything, wired is going on?
>
> I do not understand this at all. Do you mean /sbin/rc2.d?
> By "wired" do you mean the soft-links?
>
OK, It has been a while since I worked on HPUX. IIRC
The kernel calls /sbin/rcN when it changes to runlevel N
/sbin/rcN then does some stuff and executes all the scripts in /sbin/rcN,d
I do not mean "wired" like soft links I mean how exactly does HPUX call the
init scripts, does it do anything odd that might affect the perl (phew got
it in) scripts. Have they changed it in this version
My email address is valid, just leave the stuart gall in to avoid being
filtered.
Perhaps we should continue this by email.
--
Stuart Gall
------------------------------------------------
This message is not provable.
------------------------------
Date: Fri, 02 Nov 2001 14:39:49 -0500
From: Terry <tdupuis@omafra.gov.on.ca>
Subject: Re: help with simple script
Message-Id: <3BE2F684.379F36A5@omafra.gov.on.ca>
X-No-Archive: Yes
Quite right, I sent the wrong message. First off thanks for the help so
far, I should have thought more closely about the domains I used in my
example as what I used won't work. Below is what I meant to post:
==================================
Dim domain1, domain2, domain3, domain4, refDomain
refDomain = Request.ServerVariables("HTTP_REFERER")
domain1 = inStr(refDomain,"http://test.omafra.gov.on.ca")
domain2 = inStr(refDomain,"http://www.omafra.gov.on.ca")
domain3 = inStr(refDomain,"http://www.omafra.on.ca")
domain4 = inStr(refDomain,"http://www.gov.on.ca")
If domain1 <> True And domain2 <> True And domain3 <> True And domain4 <>
True Then
Response.Write("Error.<br><br>This script cannot be run from this
domain.")
Response.End
End If
==================================
Thanks Tassilo,
Terry
Tassilo von Parseval wrote:
> Terry wrote:
>
> > X-No-Archive: Yes
> >
> > Hello,
> >
> > Could someone help converting this to perlscript?
>
> You already asked that a couple of days ago and I received an answer.
>
> [...]
>
> Tassilo
>
> --
> $a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
> [1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
> (chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
> ),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
> 10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
> ord(chr($h->{$_}))))};
------------------------------
Date: Fri, 2 Nov 2001 20:20:23 +0100
From: "Emping Melindjo" <emelindjo@hotmail.com>
Subject: Re: How to: If (exactstring) then.. [learning Perl]
Message-Id: <9rurgu$ke3$1@scavenger.euro.net>
Thank you for your comment. In reply to my first question "Lao" brought me
on the right track. The thing with the brackets was just to clearify my
question, sorry for the misunderstanding. Hope to frame my questions better
next time. ;-)
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:3be2d3a9$1@news.microsoft.com...
> "Emping Melindjo" <emelindjo@hotmail.com> wrote in message
> news:9rtuqv$1hkk$1@scavenger.euro.net...
> > I want to test the exact content of: ($Category{$line})
> > if ($Category($line) = "bike" then ...
>
> Couple of issues:
> - the brackets are unbalanced
> - the keyword to open a new block is "{" instead of "then"
> - to access the value of an element in a hash you use curly braces, not
> brakets (you got it right in the text and wrong in the code)
> - the single "=" is the assignment operator, i.e. your are assigning the
> value "bike" to $Category{$line} and then the "if" tests the return value
of
> the assignment. Not very useful.
> Instead you want to use "eq" which compares text.
> - a minor issue: You don't need any stringification on the text "bike" (it
> doesn't contain any variables or special characters which would need to be
> interpreted). You should get into the habit of using single quotes instead
> of double quotes for those strings.
>
> if ($Category{$line} eq 'bike') {
>
> jue
>
>
------------------------------
Date: Fri, 02 Nov 2001 19:12:35 -0000
From: David Wall <darkon@one.net>
Subject: Re: One liners vs. verbose code
Message-Id: <Xns914D9077B4D21darkononenet@207.126.101.97>
Lou Moran <lmoran@wtsg.com> wrote on 02 Nov 2001:
> --I realize perlgolf is for fun but I have been wondering lately if
> there is any reason to code in a golf-esque manner.
It depends. :-)
> --Would it make programs/scripts run faster or would it just make the
> next Sys Admin's job harder?
It depends. :-)
>
> --(This all started when my boss put one of my scripts on a projector
> and said to a group (essentially) "I don't want you all coding like
> this. It's too clear." (I comment, a lot... but I write scripts and
> then don't go back to them for months...OK I'm not all that bright,
> there I said it)) (:
Hmmph. Maybe you need a new boss? If it helps you get your job done more
easily, put comments all over. Comments are there for helping make the
code more understandable and maintainable; why shouldn't you use them? I
suppose you COULD overdo the comments, but I suspect most people tend to
err on the side of too few comments. Maybe your boss wants programs to be
hard to maintain for job security purposes?
I'm not anywhere near as experienced at programming as many of the people
in clpm, so I'll quote _Programing_Perl_ (3rd ed., pp. 593-594):
"In general, the shorter and simpler your code is, the faster it runs, but
there are exceptions. ... Note that optimizing for time may sometimes
cost you in space or programmer efficiency (indicated by conflicting hints
below). Them's the breaks. If programming was easy, they wouldn't need
something as complicated as a human being to do it, now would they?"
Or from perlstyle:
"Just because you CAN do something a particular way doesn't mean that
you SHOULD do it that way. Perl is designed to give you several
ways to do anything, so consider picking the most readable one."
--
David Wall
darkon@one.net
------------------------------
Date: Fri, 02 Nov 2001 19:21:18 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: One liners vs. verbose code
Message-Id: <slrn9u5peg.dob.tadmc@tadmc26.august.net>
Lou Moran <lmoran@wtsg.com> wrote:
>--I realize perlgolf is for fun but I have been wondering lately if
>there is any reason to code in a golf-esque manner.
No.
There _are_ arguments for writing more succinct code, but Golf
takes that to the ridiculous extreme.
>--Would it make programs/scripts run faster or would it just make the
>next Sys Admin's job harder?
I don't know about the sysadmin, but it will surely make the
programmer's job harder (or even impossible if their Perl
skills aren't astounding).
>--(This all started when my boss put one of my scripts on a projector
>and said to a group (essentially) "I don't want you all coding like
>this. It's too clear."
Does this boss wear a pointy hair style?
If is fortunate for you that your boss is stupid, it will make
it easier for you to eventually take his/her job. :-)
(It is possible that your paraphrase above does not capture the
essence of what was really said/meant though.
)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 02 Nov 2001 19:32:06 -0000
From: David Wall <darkon@one.net>
Subject: Re: One liners vs. verbose code
Message-Id: <Xns914D93C669161darkononenet@207.126.101.97>
tadmc@augustmail.com (Tad McClellan) wrote on 02 Nov 2001:
> Lou Moran <lmoran@wtsg.com> wrote:
>>--(This all started when my boss put one of my scripts on a projector
>>and said to a group (essentially) "I don't want you all coding like
>>this. It's too clear."
>
>
[snip]
> (It is possible that your paraphrase above does not capture the
> essence of what was really said/meant though.
> )
That occurred to me as well after I'd already posted a followup.
--
David Wall
darkon@one.net
------------------------------
Date: 2 Nov 2001 14:54:52 -0800
From: smig1@visto.com (Gene Smilgiewicz)
Subject: Perl semi-newbie looking to split HTML into XSL & XML
Message-Id: <89d13a67.0111021454.5e56c5fb@posting.google.com>
I've been tasked to build a set of routines to generate sets of
XSL/XML files, among other things, from a large body of HTML files.
In getting up to speed on the Perl I need to know to develop this
thing, I find that I'm up to my neck in a sea of of goodies -- like
Sean Burke's great HTML::Treebuilder docs and parsing examples -- but
I'm afraid I'll need a lifesaver or two before I drown in it all.
Treebuilder seems to be a good way to go because it's got all the
methods needed to navigate through the HTML, isolate text and
content-oriented tags, etc. Has anyone out there done something like
this? Should I be approaching this differently (please don't suggest
a regex script-fest 'cause that's what I've got to replace)?
Thanks in advance for any guidance!
-Gene
------------------------------
Date: 2 Nov 2001 22:44:12 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: pervent multiple instances of a server
Message-Id: <1004741052.632316@hpvablab.cup.hp.com>
Benjamin Goldberg <goldbb2@earthlink.net> writes:
>6. Count, using stat, the number of "links" to the program file. It
>should be 2: one directory entry, one open file [perl holding the script
>open]:
> die "Program is already running\n"
> if (stat $0)[3] > 2;
>or:
> die "Program is already running\n"
> if (stat DATA)[3] > 2;
Huh?!? Run that by me again!
(In other words, I don't believe that works. At least not on my *nix
boxes!)
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Fri, 02 Nov 2001 22:58:53 +0100
From: Uwe Schneider <uwe@richard-schneider.de>
To: felix_schattschneider@ccmconsult.de
Subject: Re: Q: exclusive bind() on Unix Domain Socket?
Message-Id: <3BE3171D.6BB73624@richard-schneider.de>
Felix Schattschneider wrote:
>
> Hi,
>
> here's my problem:
> I wrote a small server which listen()s on a Unix Domain Socket
> <snip>
> $server = IO::Socket::UNIX->new( Type => SOCK_STREAM,
> Local => $SOCKNAME,
> Listen => 1);
>
> die "Cannot setup server $!" unless $server;
> </snip>
> but I don't want a second instance of that server being able to bind() to
> that socket $SOCKNAME (which it does at the moment).
> Is there any way to do this?
> I didn't find anything in the IO::Socket manpage and it doesn't make sense
> to flock() the socket (I need my clients to connect to it)
This is strange: On Linux here the second process can't bind the socket
("Address in use"), which is the expected behaviour. What platform do
you use?
Uwe
--
Uwe Schneider | Telefon +49 7244 / 609504
Karlsdorfer Str. 31 | Mail uwe@richard-schneider.de
DE-76356 Weingarten | http://www.richard-schneider.de/uwe
Linux - OS al dente!
------------------------------
Date: 2 Nov 2001 16:04:06 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Q: exclusive bind() on Unix Domain Socket?
Message-Id: <9rv58m$kc3$1@bunger.cs.utexas.edu>
In article <9rujer$voqe0$1@ID-13380.news.dfncis.de>,
Felix Schattschneider <felix_schattschneider@ccmconsult.de> wrote:
>I wrote a small server which listen()s on a Unix Domain Socket
:
:
>but I don't want a second instance of that server being able to bind() to
>that socket $SOCKNAME (which it does at the moment).
>Is there any way to do this?
>I didn't find anything in the IO::Socket manpage and it doesn't make sense
>to flock() the socket (I need my clients to connect to it)
flock() does an advisory lock. If your clients don't call flock() (or
some other locking function), they won't even know that the lock
exists.
- Logan
--
"In order to be prepared to hope in what does not deceive,
we must first lose hope in everything that deceives."
Georges Bernanos
------------------------------
Date: Fri, 2 Nov 2001 14:38:35 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Taint problem with BEGIN block
Message-Id: <22956-3BE3044B-99@storefull-246.iap.bryant.webtv.net>
Very informative. Thanks Tad. You're very hard on me; but I guess I
deserve it.
Regards,
--Dennis
------------------------------
Date: Fri, 2 Nov 2001 22:46:34 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <9rv37f$big$3@usenet.otenet.gr>
"Ilmari Karonen" <iltzu@sci.invalid> wrote in message
news:1004651588.15082@itz.pp.sci.fi...
> In article <9rpr5h$4r5$2@usenet.otenet.gr>, Stuart Gall wrote:
> >((0-1) % 256) ahould equal -1
>
> Allow me to disagree.
>
>
> >Hmmm. I guess what perl does is more likely to be usefull to a
programmer,
> >like most of what perl does. But it does not follow the mathematical
> >definition of modulus
>
> Actually, what perl does is rely on the integer modulus operator of the
> C compiler it was built with. This means that, in current versions of
> perl, modulus is only consistently defined across different platforms
> for small non-negative integers (where "small" means "less than 2**31").
Can you expand on this? If it relies on the modulus operator of the
underlying C compiler wouldn't that mean it is not consistent for numbers <
2^31
Why does it lose consistency after 2^31, I might expect it to lose accuracy
but not consistency.
--
Stuart Gall
------------------------------------------------
This message is not provable.
------------------------------
Date: 2 Nov 2001 23:01:09 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <1004741348.21037@itz.pp.sci.fi>
In article <9rsriv$2ai5$1@agate.berkeley.edu>, Ilya Zakharevich wrote:
>[A complimentary Cc of this posting was sent to
>Ilmari Karonen
><usenet11627@itz.pp.sci.fi>], who wrote in article <1004651588.15082@itz.pp.sci.fi>:
>
>> Actually, what perl does is rely on the integer modulus operator of
>> the C compiler it was built with.
>
>Hmm, are you still running v4.036?
Whoops, you're right. What I said above applies to modern versions of
perl only if the "use integer" pragma is in effect. The 2**31 upper
limit is still there for 5.005, but later versions have that fixed too.
In fact, looking at the code (pp_modulo in pp.c) in bleadperl, it seems
it already uses fmod() internally for large numbers -- the operands are
just truncated to integers before the result is computed.
IMHO that's silly. But that issue has been discussed here before.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
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 2056
***************************************