[16269] in Perl-Users-Digest
Perl-Users Digest, Issue: 3681 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 16 06:05:23 2000
Date: Sun, 16 Jul 2000 03:05:09 -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: <963741909-v9-i3681@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 16 Jul 2000 Volume: 9 Number: 3681
Today's topics:
Re: Accessing string martho@my-deja.com
Re: Anyone working on any XS books? (Clinton A. Pierce)
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! (Randal L. Schwartz)
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! <dr_den_net@my-deja.com>
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! (NP)
Re: Bizarre BEGIN block problem (brian d foy)
Re: CGI email on NT server (Russell Smallwood)
Re: flock nonsense ? martho@my-deja.com
Re: GD module, displaying an image in a browser <pepin@worldnet.att.net>
Re: Help with Regular Expression (Tad McClellan)
Re: Help with Regular Expression <godzilla@stomp.stomp.tokyo>
Interfacing Perl with MIME : help needed <bo@bo.com>
Re: Interfacing Perl with MIME : help needed <bcaligari@shipreg.com>
Re: Interfacing Perl with MIME : help needed (Jorgen Grahn)
Is there a Perl bug list? <nospam.nicedoctor@hotmail.com>
Re: Locking a file martho@my-deja.com
Re: Net::Smtp problems <jdNOjdSPAM@syncon.ie.invalid>
Re: Net::Smtp problems (Clinton A. Pierce)
Re: NET::SMTP sanity check please (Russell Smallwood)
Re: Perl can't add ! <kmsproule@worldnet.att.net>
Re: Perl can't add ! <cal@iamcal.com>
Re: Perl Expert? I need help! <akurczyn@usa.net>
Re: Perl Expert? I need help! <akurczyn@usa.net>
programming tools and techniques acunet3278@my-deja.com
Re: Running Active Perl under NT (Russell Smallwood)
Re: Time in mili-seconds martho@my-deja.com
Re: Time in mili-seconds martho@my-deja.com
Understanding the regex in "commify" (perlfaq5) <mauldin@netstorm.net>
Re: Upper-to-lower case problem <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 16 Jul 2000 08:46:29 GMT
From: martho@my-deja.com
Subject: Re: Accessing string
Message-Id: <8krsp3$ja5$1@nnrp1.deja.com>
> perldoc -f length
> perldoc -f substr
>
> If you don't know what means, type it in at a command prompt.
... and nothing happens ! I search my hole perl-installation, the files
are not there. I think, that I didn't download the doc-files. Where can
I get them ?
Regards
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 01:33:18 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Anyone working on any XS books?
Message-Id: <yh8c5.39270$fR2.354889@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <3970EE81.AFF26CC5@attglobal.net>,
Drew Simonis <care227@attglobal.net> writes:
> I've been reading over perlxstut and perlguts, but I must say that
> I think they are a bit sparse. (and hard to understand, for me,
> anyway) I wonder:
>
> 1. Is anyone working on a Perl XS book?
> 2. How common is it to use XS, meaning, will learning about
> them benefit me in a real way, or will my brain just expand?
I've been programming perl for quite a few years and never felt the need
for XS programming at all.
Until recently.
Then I came across a project where I have to put a large amount of legacy
C code on the web. That code would be nearly impossible to re-write in
anything less than two years. XS is allowing me to subvert the screen
manager and treat perl like a screen-scraping application on the insides.
It's great. Interaction with the application and no fuss.
XS is almost unnecessary until you need it. Then you really need it.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: 15 Jul 2000 20:07:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <m1zoniepsi.fsf@halfdome.holdit.com>
>>>>> "NP" == NP <nvp@spamnothanks.speakeasy.org> writes:
NP> : I would genuflect if you'd write a book on XS. I'd pay you money
NP> : if you offered a class on XS. I'd worship you if, after reading
NP> : said book or taking said class, I clearly understood XS =)
NP> IMO, there's not a huge market for XS. The usually quiet perl-xs
NP> mailing list and the (small) number of questions about XS on USENET is
NP> proof of this. It IS possible that there are a million of Perl folks
NP> who are interested in learning XS but I just don't think so.
I have a very nice "intro to XS" training module that was custom-built
for the first client to ask for it two years ago. It has not been
asked for since. :) Maybe I'll just make it open doc.
There's not a lot of call for it. There's some XS stuff in APP and
EPP (but not the newer EoPP), and even that's sorta, just, there. :)
print "Just another Perl trainer,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 16 Jul 2000 03:55:58 GMT
From: dr_den_net <dr_den_net@my-deja.com>
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <8krbo9$81r$1@nnrp1.deja.com>
In article <8kgjnu$k4j$1@nnrp1.deja.com>,
p3rlc0dr@my-deja.com wrote:
> In article <%uPa5.6$Sm.1942@vic.nntp.telstra.net>,
> "Wyzelli" <wyzelli@yahoo.com> wrote:
> >
> > I would have take 'proper case letters' to mean the correct use of
> mixed
> > case (upper and lower) when starting sentences and for nouns etc.
It
> is
> > reasonable to query uri, but then most of us have just learned to
> ignore
> > basic typo's and oddities and look for the Perls of wisdom.
>
> I have not been come across one 'Perl of wisdom' from 'uri'. How ever
> I do like John Stanley. He is a very nice and helpful fellow.
>
> --
> Ganesha, p3rlc0dr and WEB MISTRESS
> Guestbooks, hit counters, shopping carts: Get Matt's Script Archive
> "There is no such thing as being a stupid woman."
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 05:13:42 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <awbc5.350439$VR.5273035@news5.giganews.com>
On 15 Jul 2000 20:07:25 -0700, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
:
: I have a very nice "intro to XS" training module that was custom-built
: for the first client to ask for it two years ago. It has not been
: asked for since. :) Maybe I'll just make it open doc.
Dean Roehrich (sp?) also wrote a pretty decent doc on XS in C *and*
C++ -- that's available on CPAN.
: There's not a lot of call for it. There's some XS stuff in APP and
: EPP (but not the newer EoPP), and even that's sorta, just, there. :)
Hello, echo in room? :-)
--
Nate II
------------------------------
Date: Sun, 16 Jul 2000 00:50:24 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Bizarre BEGIN block problem
Message-Id: <brian-1607000050250001@124.sanjose-01-02rs16rt.ca.dial-access.att.net>
In article <Dwnb5.63003$_b3.1836074@newsread1.prod.itd.earthlink.net>, "Ed Foy" <ed@nospam.com> wrote:
> The code works, but
>because of the reported syntax error, I'm wondering if this indicates
>that there may be some other problem elsewhere. This looks like a bug so
>I am trying to determine its extents and implications.
it's been fixed, so check the patches to Perl 5.004 and find out
for yourself.
--
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ
<URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 16 Jul 2000 01:43:21 -0500
From: rsmallwood@mindspring.com (Russell Smallwood)
Subject: Re: CGI email on NT server
Message-Id: <MPG.13db239165f30ab6989762@news.giganews.com>
In article <sn1luv5lnd657@corp.supernews.com>, patty@xidd.com belched:
> I've moved my site over from a UNIX platform to an NT platform and I'm
> experiencing some difficulties with the cgi scripts. I've worked out all
> of the bugs with the exception that the sendMail function is not working.
> After researching I now know that this function does not work on NT and
> I've tried the BLAT.EXE command but it isn't working for me.
>
> If someone could direct me to a location for where I could obtain
> information/demos on how to send email through a CGI Script on an NT
> server I would be very thankful!
>
> Thanks in advanced!
> Patrick
>
> P.S.: Below is the source I'm using for the sendMail function.
>
> sub send_email
> {
> $to = "info\@xidd.com";
> open(MAIL, "|/usr/sbin/sendmail -t -n -oi");
> print MAIL "From: $Variable{'email'}\n";
> print MAIL "To: $to\n";
> print MAIL "Subject: Reply to XIDD INTERACTIVE\n\n";
>
> # print out the form results
> print MAIL "REPLY FOR XIDD INTERACTIVE\n";
> print MAIL "\n";
> print MAIL "Name: $Variable{'name'}\n";
> print MAIL "Title: $Variable{'title'}\n";
> print MAIL "Company: $Variable{'company'}\n";
> print MAIL "Phone#: $Variable{'phone'}\n";
> print MAIL "Fax#: $Variable{'fax'}\n";
> print MAIL "E-mail: $Variable{'email'}\n";
> print MAIL "\n";
> print MAIL "Message for XIDD INTERACTIVE:\n";
> print MAIL "$Variable{'comments'}\n";
> close(MAIL);
> }
>
> --
> Posted via CNET Help.com
> http://www.help.com/
>
NET::SMTP
Russell
------------------------------
Date: Sun, 16 Jul 2000 08:47:45 GMT
From: martho@my-deja.com
Subject: Re: flock nonsense ?
Message-Id: <8krsre$jha$1@nnrp1.deja.com>
> Yes: don't release the lock until you're done with the file. If you
> need to read AND write from it, then open it for reading and writing.
Okay, thats the solution. I didnÄt know that you could open a file for
both. Thanks.
> See the open documentation.
Where can I get it ? Everybody tells me to look at "perldoc ....", but
in my perl-installtion, there is no file called so. I thank, I didn't
get the doc-files.
Regards
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 01:08:32 GMT
From: "Joseph Pepin" <pepin@worldnet.att.net>
Subject: Re: GD module, displaying an image in a browser
Message-Id: <kW7c5.10095$tI4.796028@bgtnsc05-news.ops.worldnet.att.net>
Chello, Krakle is incorrect here. The latest & greatest GD supports JPEG,
PNG, and several others. It can read more formats than it can write. It also
supports TrueType fonts. I don't know what's wrong with your code, but
you've got the GD part correct. What does your HTML look like?
> > What's the problem and how to solve it??? Does
> someone have the solution??
> >
> > Thanks in advance.
> >
> > Stéphane
> >
> >
>
>
> ---GD is a graphics library that generates images
> in the GIF format not jpeg format...
>
> Change print "Content-type:image/jpeg\n\n";
> to
> print "Content-type:image/gif\n\n";
>
> Also the new version of GD generates PNG...
>
> GD is minimal i reccomend using GIMP on a unix
> maching... Or atleast GD&TTF (freetype AND gd)
> from the-labs.com
>
> ---krakle
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Sat, 15 Jul 2000 21:46:15 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with Regular Expression
Message-Id: <slrn8n24v7.iac.tadmc@magna.metronet.com>
On Sat, 15 Jul 2000 16:57:10 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Brian Scheller wrote:
>
>> I need some help developing a regular expression....
>
>> ...the string that I am attempting to parse looks like:
>
>> "Engaños (Quackery);Fraude en el campo de la salud (Health fraud)"
^
^ what if that needed to be an upper case O ?
>> Can anyone
^^^^^^
Be careful with that part...
>> offer a suggestion of a regular
>> expression that would ignore the constructs of &[^;]*;, i.e. character
>> entities, but still be able to find the other semicolon? ....
>
>
>In closing you will find a test script and printed results.
>You will read four no-brainer methods to attain your goal.
Read the next paragraph.
Recognize the restrictions it requires.
Then just stop reading if you are clever.
>First method locates " ;F " in your string and replaces
>the semi-colon with a split vertical bar, then splits
>your string into two variables, as you request. This
>method relies on your dictionary being standardized
>with a capital letter always following a semi-colon,
>which it should if a commercial dictionary or correctly
>written dictionary if privately created.
So if you have a special character (i.e. an entity)
preceding an upper case character anywhere in your data,
this method will not work correctly.
e.g.
&tiny-right-arrow;Arrow is pointing at me;Definition of "arrow is pointing at me".
Also, if you have a field that does not start with a upper
case letter this method will not work correctly.
Also also, if you ever have more than 2 fields,
this method will not work correctly.
I think it is possible to get a solution that will avoid
all of those restrictions...
>Godzilla Rocks!
Says you.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Jul 2000 20:39:51 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with Regular Expression
Message-Id: <39712E87.3FADA9D8@stomp.stomp.tokyo>
Tad McClellan wrote:
(snipped blatherings)
> >Godzilla Rocks!
> Says you.
Reads like insane jealousy to me Mr. McClellan. Reads
like you don't have enough self-confidence to master
your own ego. Reads like you may not know Perl very
well, nor yourself.
Doesn't it just piss you off to have to change givens,
have to change parameters, otherwords tell some lies
to massage and band-aid your bruised fragile ego?
Godzilla!
------------------------------
Date: Sat, 15 Jul 2000 23:04:43 -0400
From: "Bo" <bo@bo.com>
Subject: Interfacing Perl with MIME : help needed
Message-Id: <8kr8gj$k54$1@slb7.atl.mindspring.net>
We have a user who needs to send web-based mail in *plain-text*
format, WHILE attaching .jpeg images to the messages, which would seem
to involve MIME. Can this be done with Perl scripts and how?
Thanks. Please reply in the newsgroup.
------------------------------
Date: Sun, 16 Jul 2000 10:34:30 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: Interfacing Perl with MIME : help needed
Message-Id: <8krrf4$rkt$1@news.news-service.com>
"Bo" <bo@bo.com> wrote in message
news:8kr8gj$k54$1@slb7.atl.mindspring.net...
> We have a user who needs to send web-based mail in *plain-text*
> format, WHILE attaching .jpeg images to the messages, which would seem
> to involve MIME. Can this be done with Perl scripts and how?
>
> Thanks. Please reply in the newsgroup.
>
If you search CPAN you will definitely find some modules to help you with
the job.
Alternatively, you might want to encode the plain text as quoted printable,
the jpeg as BASE-64 and put all together in one perl script. I recommend
that you go through RFCs 822, 1521 & 1522
But also, this does not sound right and I'm sure I'm missing something
Brendon
+++
------------------------------
Date: Sun, 16 Jul 2000 10:04:33 GMT
From: jgrahn-nntp@algonet.se (Jorgen Grahn)
Subject: Re: Interfacing Perl with MIME : help needed
Message-Id: <RMfc5.1079$652.40081@newsc.telia.net>
On Sat, 15 Jul 2000 23:04:43 -0400, Bo <bo@bo.com> wrote:
>We have a user who needs to send web-based mail in *plain-text*
>format, WHILE attaching .jpeg images to the messages, which would seem
>to involve MIME. Can this be done with Perl scripts and how?
Last time I heard Perl was Turing-complete so, yes, it can be done ;-)
Try http://www.cpan.org for MIME-related Perl modules.
[irrelevant newsgroups trimmed]
/Jorgen
--
// Jorgen Grahn <jgrahn@ OpenPGP key: 0x0B609882
\X/ algonet.se>
------------------------------
Date: Sun, 16 Jul 2000 03:18:58 GMT
From: "Mark Lewis" <nospam.nicedoctor@hotmail.com>
Subject: Is there a Perl bug list?
Message-Id: <CQ9c5.8003$dT5.205295@newsread2.prod.itd.earthlink.net>
Hello,
Where can a comprehensive list of confirmed Perl bugs be found? The only
thing I have be able to find is an outdated list at perl.com.
TIA!
ML
------------------------------
Date: Sun, 16 Jul 2000 08:42:16 GMT
From: martho@my-deja.com
Subject: Re: Locking a file
Message-Id: <8krsh7$j7u$1@nnrp1.deja.com>
> What's the best way to say "use the available documentation
> resources"?
Okay, I see the problem: With the download of my win-perl-bins, I didn't
get any doc-files. Where can I get them ?
> > I could use flock(), but if the user aborts or the connections
> > breaks down, the file would be locked forever...
>
> What leads you to believe that?
I understood flock the wrong way. What I need is a locking-mechanism
that works beyhond flock.
The locking should be for accessing files on a web-server, so the
locking has to be global and it has to stay until somebody says: unlock.
How is it done ?
Regards
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 15 Jul 2000 18:02:56 -0700
From: deno <jdNOjdSPAM@syncon.ie.invalid>
Subject: Re: Net::Smtp problems
Message-Id: <30a7589c.55654d8e@usw-ex0105-036.remarq.com>
I have increased the timeout to limit. This script does not work
reliably connecting to 3 different mail hosts which are in the
same room (never mind the same network).
The mail hosts are rock solid, hence the question. (Yes I have
tried another workstation also)
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Sun, 16 Jul 2000 01:38:18 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Net::Smtp problems
Message-Id: <em8c5.39271$fR2.354889@news1.rdc1.mi.home.com>
[posted and mailed]
In article <30a7589c.55654d8e@usw-ex0105-036.remarq.com>,
deno <jdNOjdSPAM@syncon.ie.invalid> writes:
>
> I have increased the timeout to limit. This script does not work
> reliably connecting to 3 different mail hosts which are in the
> same room (never mind the same network).
>
> The mail hosts are rock solid, hence the question. (Yes I have
> tried another workstation also)
Who are you? What do you want? Is this even a Perl question?
Where's the Perl? What script? I see no script here. What's the
question? There's no question here! What workstation?
What in the name of bloody Hell are you talking about?
Or are we expected to wade through the last few weeks of
comp.lang.perl.misc looking for your (spam-blocked) e-mail address to
try to reconstruct some earlier thread in which you may or may not
have asked an intelligible question?
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours!
clintp@geeksalad.org for details see http://www.geeksalad.org
"If you rush a Miracle Man,
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 16 Jul 2000 01:44:52 -0500
From: rsmallwood@mindspring.com (Russell Smallwood)
Subject: Re: NET::SMTP sanity check please
Message-Id: <MPG.13db23f12b1ccfcb989763@news.giganews.com>
In article <1268.232T1550T274950postmaster@rask.nospam.kampsax.k-
net.dk>, postmaster@rask.nospam.kampsax.k-net.dk belched:
> On 14-Jul-00 03:18:57, Russell Smallwood wrote the following about "NET::SMTP sanity check please":
>
> > I have a stand-alone NT server that I'm hosting a company site on and
> > the only smtp server that it has access to is mail.mindspring.com. I'm
> > guessing that, once correctly identified, I should be able to send a
> > message to that server using net::smtp..right? How do i send a
> > password?
>
> Password? What password? You just said your server has access to
> mail.mindspring.com, didn't you? Besides, mail.mindspring.com does not
> appear to support password authentication at all (according to the EHLO
> response). They might be using POP-before-SMTP for authentication, but then
> you should look at the Net::POP3 module.
>
> > Am I missing the point,
>
> Yes, by a country mile. It would be good for you to read the RFCs
> defining the SMTP protocol. As a minimum, read RFC 821.
>
> Regards,
>
> /ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻTŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\
> | Rask Ingemann Lambertsen | postmaster@rask.nospam.kampsax.k-net.dk |
> | A4000, 896 kkeys/s (RC5-64) | "ThrustMe" on XPilot and EFnet IRC |
> | 03h:42m SLEEP? I'm a programmer! |
>
>
You are right, I made an assumption when first trying NET::SMTP that a
problem I was encountering was due to nto being able to connect to the
server. Thanks for the info, I'll read the docs specified.
Russell
------------------------------
Date: Sun, 16 Jul 2000 03:16:14 GMT
From: "Kevin M. Sproule" <kmsproule@worldnet.att.net>
Subject: Re: Perl can't add !
Message-Id: <2O9c5.10477$tI4.832438@bgtnsc05-news.ops.worldnet.att.net>
"Stuart Horner" <stuart@unidev.com> wrote in message
news:NUVb5.16320$EQ3.572715@news-east.usenetserver.com...
> I'm having a Perl adding error!
>
> Here is the code:
>
> foreach $key (@Sorted)
> {
> print "\"$InitialAmount\" + \"$SearchResults{$key}{'Amount'}\" = ";
> $InitialAmount = $SearchResults{$key}{'Amount'} + $InitialAmount;
> print "\"$InitialAmount\"\n";
> }
>
> Here is a snippit of the output:
>
> "823.35" + "24.95" = "848.3"
> "848.3" + "24.95" = "873.25"
> "873.25" + "24.95" = "898.200000000001"
> "898.200000000001" + "24.95" = "923.150000000001"
> "923.150000000001" + "24.95" = "948.100000000001"
> SNIP
> What is going on with this?? I'm just adding two numbers together, from a
> hash of a hash!
>
> I've had this problem on two different machines running two different
> operating systems, on two different versions of Perl.
>
> Sun OS 7 Perl 5.003 and RedHat 6.1 (I don't know the kernal version) Perl
> 5.6
>
> All the printing is only to show the results at each step for debugging.
> (i.e. finding out where the heck that .000000000001 is coming from).
>
> Any responses appreciated!!
>
> Regards,
>
> Stuart Horner
> stuart@NOSPAMPLEASE.core-comm.com
>
> Please remove the nospamplease. to e-mail.
>
Stuart,
What you are now learning about is called Floating Point Approximation.
This occurs in all computer languages. The following example is in C:
// fptest.c - Kevin Sproule 7/15/2000
#include <stdio.h>
#include <dos.h>
int main()
{
double init=823.35,
inc=24.95;
int i;
for (i=0; i<3; i++)
{
printf("%.13f + %.13f = ",init,inc);
init += inc;
printf("%.13f\n",init);
}
return 0;
}
Results:
823.3500000000000 + 24.9500000000000 = 848.3000000000001
848.3000000000001 + 24.9500000000000 = 873.2500000000001
873.2500000000001 + 24.9500000000000 = 898.2000000000002
These results are similar to what you encountered. The errors creep in
because computers are only capable of approximating the floating point
values. It is necessary to use whole numbers or to round your results to
keep things accurate. Some folks like to do all integer math while other
prefer to just round the results of calculations.
Simple Perl rounding:
$result = int(($result + .005) * 100) / 100; # round to 2 places
Yours truly,
Kevin Sproule
------------------------------
Date: Sun, 16 Jul 2000 10:40:41 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: Perl can't add !
Message-Id: <gqfc5.1076$Yp.30562@news6-win.server.ntlworld.com>
"Kevin M. Sproule" <kmsproule@worldnet.att.net> wrote in:
:
: Simple Perl rounding:
:
: $result = int(($result + .005) * 100) / 100; # round to 2 places
:
easier to do:
$result = sprintf("%.2f",$result);
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: Sun, 16 Jul 2000 02:02:59 -0500
From: "Alejandro Kurczyn" <akurczyn@usa.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <39716dd1_2@excalibur.gbmtech.net>
From: "Tad McClellan" <tadmc@metronet.com>
> [ Please put your comments *following* the quoted text that you
> Please do not quote an _entire_ article. Quote just enough to
> Please do not quote .sigs
Yeah, sorry about that. It's been some years since I posted on Usenet :-)
> That looks just like the code I posted in a different subthread
> (except you've made it harder to read).
I don't mind loosing a few spaces...
> If you have a question about my code, followup to the article
> where I posted the code.
It's not about "your code", it's a valid question regarding Perl. I've seen
some tricks performed using regex, when other functions are available. I
just want to know if there is any difference whatsoever.
> Please don't break stuff by copying it from one subthread
> to another.
I didn't copied anything, my post includes "my code", I didn't even had your
message available on the server when I responded.
> >Is it better to use regexps if there is already a function to do it?
>
> We cannot answer unless "better" is defined.
>
> What is "better" depends on what you want to optimize.
>
>
> Speed?
>
> Size of source code?
>
> Size of executable?
>
> Memory usage?
>
> Disk usage?
>
> Development time?
>
> Maintenance time?
>
>
>
> For code that I post, you can nearly always assume the last one there.
OK, can you give any light on the other ones? Myself I prefer good
performance (that's a function of Speed, I/O, and Memory).
Regards,
-Alejandro
------------------------------
Date: Sun, 16 Jul 2000 02:02:59 -0500
From: "Alejandro Kurczyn" <akurczyn@usa.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <39716f1a_1@excalibur.gbmtech.net>
From: "Tad McClellan" <tadmc@metronet.com>
> [ Please put your comments *following* the quoted text that you
> Please do not quote an _entire_ article. Quote just enough to
> Please do not quote .sigs
Yeah, sorry about that. It's been some years since I posted on Usenet :-)
> That looks just like the code I posted in a different subthread
> (except you've made it harder to read).
I don't mind loosing a few spaces...
> If you have a question about my code, followup to the article
> where I posted the code.
It's not about "your code", it's a valid question regarding Perl. I've seen
some tricks performed using regex, when other functions are available. I
just want to know if there is any difference whatsoever.
> Please don't break stuff by copying it from one subthread
> to another.
I didn't copied anything, my post includes "my code", I didn't even had your
message available on the server when I responded.
> >Is it better to use regexps if there is already a function to do it?
>
> We cannot answer unless "better" is defined.
>
> What is "better" depends on what you want to optimize.
>
>
> Speed?
>
> Size of source code?
>
> Size of executable?
>
> Memory usage?
>
> Disk usage?
>
> Development time?
>
> Maintenance time?
>
>
>
> For code that I post, you can nearly always assume the last one there.
OK, can you give any light on the other ones? Myself I prefer good
performance (that's a function of Speed, I/O, and Memory).
Regards,
-Alejandro
------------------------------
Date: Sun, 16 Jul 2000 08:25:03 GMT
From: acunet3278@my-deja.com
Subject: programming tools and techniques
Message-Id: <8krrgp$ihl$1@nnrp1.deja.com>
I am taking a beginner C language course.
Could you kindly share your experience with me?
Where can information be found about the following topics:
When, why and how to use a debugger?
What is it used for?
When, why and how to use a Make?
What is it used for?
Additionally:
What is a target?
What is build?
What is a makefile?
What is a project file?
Your advise, tips, comments, suggestions are welcome. I look forward to
hearing from you. Thank you.
--
http://www.pucho.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 01:41:10 -0500
From: rsmallwood@mindspring.com (Russell Smallwood)
Subject: Re: Running Active Perl under NT
Message-Id: <MPG.13db2315d3260fca989761@news.giganews.com>
In article <8kodu0$82a$1@gnamma.connect.com.au>,
Michael_Phipps@hotmail.com belched:
> I am having problems getting Active Perl running on my NT Box. I have done
> it before, and there is something extra you have to do with registry
> settings before you are able to call .cgi scripts on your website.
>
> Does anyone have this info?
>
> Michael Phipps
>
>
>
PerLdocs, Active Perl FAQ, web server config, questions 4 and 5
Russell
------------------------------
Date: Sun, 16 Jul 2000 08:54:07 GMT
From: martho@my-deja.com
Subject: Re: Time in mili-seconds
Message-Id: <8krt7b$jjg$1@nnrp1.deja.com>
> You can, however, get _time_ in a finer resolution, but that is
> in the Perl FAQ, so you have doubtless already seen that
> solution.
Which Perl-FAQ do you mean ? I found about 12...
> Why won't the answer given there work for you?
>
> perldoc -q time
... I didn't get the perldoc in my perl-installation. Where can I get
the doc-files ?
Reagrds
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 08:55:20 GMT
From: martho@my-deja.com
Subject: Re: Time in mili-seconds
Message-Id: <8krt9k$jl3$1@nnrp1.deja.com>
> > How can I get a timestamp in miliseconds ? "time" returns only
seconds.
>
> perldoc -q second
... thanks a lot. The problem is: I didn't get any perldoc-files in my
(old...) perl-installtion. Where can I download them ?
Reagrds
Martin
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 16 Jul 2000 02:32:54 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Understanding the regex in "commify" (perlfaq5)
Message-Id: <39711E25.8FA76108@netstorm.net>
This is a question about how the perl regex Engine works. Here's the
essential part of the code from perlfaq5 "How can I output my numbers
with commas added?".
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
Assume $_=1234567 and forget the while loop for a minute. If I
understand correctly, on its first attempt, the Engine will match the
([-+]?\d+) part of the pattern to the end of $_ because \d+ is greedy,
leaving nothing for (\d{3}). With that failed, it will try again,
matching to length($_)-1, and so on until it finally matches to
length($_)-3, at which point it can also match (\d{3}) (thus the entire
pattern), and then proceed with the replacement so that $_==1234,567.
Then it starts over with the while loop, with ([-+]?\d+) matching
everything up to the comma on the first pass, and then working backward
as before.
Is that what's going on, or is it something else?
-- Jim
------------------------------
Date: Sun, 16 Jul 2000 08:54:33 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Upper-to-lower case problem
Message-Id: <rum2ns0ng1i6o1ssg50lv83ptn1hscqdpg@4ax.com>
Tad McClellan wrote:
>>Does 5.6 really mean
>>5.006?
>
>
>No, because there is no perl 5.006.
Hah!
print "Perl version $]\n";
-->
Perl version 5.006
perl itself seems to disagree.
--
Bart.
------------------------------
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 3681
**************************************