[16138] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3550 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 15:17:31 2000

Date: Mon, 10 Jul 2000 12:17:15 -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: <963256635-v9-i3550@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3550

Today's topics:
        Beyond perl? Need advice... <phil.rennert@ioip.com>
    Re: Beyond perl? Need advice... (Steve Leibel)
    Re: Beyond perl? Need advice... (Abigail)
    Re: Beyond perl? Need advice... <flavell@mail.cern.ch>
    Re: Beyond perl? Need advice... <bcaligari@shipreg.com>
    Re: Beyond perl? Need advice... <hyagillot@tesco.net>
    Re: Beyond perl? Need advice... <jbroz@transarc.com>
    Re: Beyond perl? Need advice... <phil.rennert@ioip.com>
        bit-wise subroutines <jeep@waltz.rahul.net>
    Re: bit-wise subroutines <bwalton@rochester.rr.com>
        Bizarre copy of HASH <havanka.harri@nokia.com>
    Re: Bizarre copy of HASH <aqumsieh@hyperchip.com>
    Re: Bizarre copy of HASH (M.J.T. Guy)
        blocking read with sockets <Hajo.Wuellner@ascad.de>
        Byte compiling ... (got lost in perldocs and CTAN) <alun.moon@ncl.ac.uk>
    Re: Byte compiling ... (got lost in perldocs and CTAN) (Tad McClellan)
        Calculating Taxes <kupernik@bcn.net>
    Re: Calculating Taxes (Bernard El-Hagin)
    Re: Calculating Taxes <care227@attglobal.net>
    Re: Calculating Taxes <sariq@texas.net>
    Re: Calculating Taxes <pap@sotonians.org.uk>
    Re: Calculating Taxes <kmsproule@worldnet.att.net>
    Re: Calculating Taxes (Tad McClellan)
    Re: Calculating Taxes <gellyfish@gellyfish.com>
        Calling another perl CGI (Jimtaylor5)
    Re: Calling another perl CGI <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 08 Jul 2000 11:19:22 -0400
From: Philip Rennert <phil.rennert@ioip.com>
Subject: Beyond perl? Need advice...
Message-Id: <3967467A.C5C60EF@ioip.com>

Hi,
    I do machine learning, and I've coded up and used a lot of machine
learning algorithms in Perl, because once you've used it, why do you
want to use anything else?  In the business world, however, the attitude
is:
"You've coded & tested in Perl?  Good, you have a working prototype.
Now write the real system."
There may be a need to speed up and scale up my code.  What
languages/platforms are best for doing this (and what kind of
speed/scale improvement can be expected)?  The application will be
smallish server code operating on largish data called by numerous
clients.  I don't have a good feel for whether my Perl code is good
enough, or what to rewrite it in, but unless I can make a case, I'll
have to rewrite in Java (ugh), because it's perceived as
fast/stable/good and Perl is not.
    Any advice?  Please respond also by email to phil.rennert@ioip.com.
TIA.




------------------------------

Date: Sat, 08 Jul 2000 10:46:45 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: Beyond perl? Need advice...
Message-Id: <stevel-0807001046450001@192.168.100.2>

In article <3967467A.C5C60EF@ioip.com>, Philip Rennert
<phil.rennert@ioip.com> wrote:

> Hi,
>     I do machine learning, and I've coded up and used a lot of machine
> learning algorithms in Perl, because once you've used it, why do you
> want to use anything else?


Get the right tool for the job.  Perl doesn't scale well for large
development projects that need to be maintained over time.



  In the business world, however, the attitude
> is:
> "You've coded & tested in Perl?  Good, you have a working prototype.
> Now write the real system."

One explanation might be the Perl community's collective choice to keep
adding strange and counterintuitive language features at the expense of
documenting the language; separating the language from implementation;
making the parser consistent and correct; etc etc etc.  These issues have
been discussed at length in this newsgroup. 

The other problem with Perl for large commercial systems is that it's too
easy for inexperienced programmers to make a mess.  I'm sure nobody in
this group would ever write messy code that's impossible to maintain, but
some Perl programmers do exactly that, because the language makes it very
easy to do so.  You start with a script and keep hacking till everything
works, but you have a maintenance nightmare.  Perhaps your company
understands that a line of code, once written, must be maintained for the
next ten years.  Maintainability becomes more important in the long run
than quick initial development.

Now if you can write organized maintainable Perl code that argument goes
away, but then what about the next generation of maintenance programmers? 




> There may be a need to speed up and scale up my code. 

Oh yeah, did I mention memory leaks? 



What
> languages/platforms are best for doing this (and what kind of
> speed/scale improvement can be expected)?

Java and C++ come to mind.




The application will be
> smallish server code operating on largish data called by numerous
> clients. 

If the code is small, you can toss out all my arguments and stick with
Perl.  Perhaps you can convince your employer/client that you are capable
of writing clean, structured, organized Perl code; that you can document
it sufficiently well so that future generations of maintenance programmers
will be able to continue keeping the code clean; and that the benefit of
rapid initial development will be worth the risk of future maintenance
problems.

One rule of thumb is that Perl is suitable for a one-person project of
less than, say, 10 or 20 thousand lines of code, as long as you write
clean modular code.  Past that point, Perl becomes quite unwieldy.  For
multiple-person projects or projects staffed by mostly inexperienced
programmers, Perl has too much potential to turn into a maintenance
nightmare for the company.

Whether you agree with my reasoning or not, these are probably the
concerns of your employer/client.




 I don't have a good feel for whether my Perl code is good
> enough, or what to rewrite it in, but unless I can make a case, I'll
> have to rewrite in Java (ugh), because it's perceived as
> fast/stable/good and Perl is not.
>     Any advice?  Please respond also by email to phil.rennert@ioip.com.
> TIA.


What's your objection to Java?

Steve L


------------------------------

Date: 08 Jul 2000 14:35:54 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Beyond perl? Need advice...
Message-Id: <slrn8meu5r.rbj.abigail@alexandra.delanet.com>

Philip Rennert (phil.rennert@ioip.com) wrote on MMDIII September MCMXCIII
in <URL:news:3967467A.C5C60EF@ioip.com>:
~~ Hi,
~~     I do machine learning, and I've coded up and used a lot of machine
~~ learning algorithms in Perl, because once you've used it, why do you
~~ want to use anything else?  In the business world, however, the attitude
~~ is:
~~ "You've coded & tested in Perl?  Good, you have a working prototype.
~~ Now write the real system."

*The* business world? Maybe *your* business world. There are lots of
companies who have mission critical Perl code. There are lots of companies
who don't want a single line of code written in Perl. And anything in
between.

Please don't generalize.

~~ There may be a need to speed up and scale up my code.  What
~~ languages/platforms are best for doing this (and what kind of
~~ speed/scale improvement can be expected)?  The application will be
~~ smallish server code operating on largish data called by numerous
~~ clients.  I don't have a good feel for whether my Perl code is good
~~ enough, or what to rewrite it in, but unless I can make a case, I'll
~~ have to rewrite in Java (ugh), because it's perceived as
~~ fast/stable/good and Perl is not.

This is all to vague to answer. It might that your problem is just in
Perls alley, but it also might be that other languages are more suited
for the task. It also depends on a lot on the expertise that is in house
and what kind of support is desired and available.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


------------------------------

Date: Sun, 9 Jul 2000 00:19:24 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Beyond perl? Need advice...
Message-Id: <Pine.GHP.4.21.0007082043070.11485-100000@hpplus03.cern.ch>

On Sat, 8 Jul 2000, Philip Rennert wrote:

> There may be a need to speed up and scale up my code. 

That should become clear when you need it.

> What
> languages/platforms are best for doing this (and what kind of
> speed/scale improvement can be expected)?  The application will be
> smallish server code operating on largish data called by numerous
> clients.

There really is no alternative to analyzing the particular problem
that you have.  Benchmarking and execution profiling can help to
determine your options. But if your overheads are primarily in server
process startup, (as they are for example when using CGI on the WWW)
then it should be obvious that the way to address the problem is to
desist from starting up the server at every request; instead, arrange
for requests to be made to persistently-running server processes.

I've seen some heroic efforts spent on optimising code in the wrong
places.  Unless there is some identifiable core code (say less
than 10% of the whole) that is accounting for the bulk of the
processing resource (say 90% or more), then explicit optimisation
is a lot of effort for relatively little return.

>  I don't have a good feel for whether my Perl code is good
> enough, or what to rewrite it in, but unless I can make a case, I'll
> have to rewrite in Java (ugh), because it's perceived as
> fast/stable/good and Perl is not.

I'm sure you can appreciate that you're muddling the issues, and as
such you're impairing your chances of finding the optimal answer.  
It's a mistake to let the technical details of process design be
determined by someone who doesn't understand those technical details,
such as your upper management or their lawyers.  If they don't
understand that, then they aren't good at _their_ job either.

Perl is doing a solid job around the world, in spite of the disrepute
that has been brought on it by carelessly-written scripts that are
traded by cargo-culters.

The most spectacular savings can sometimes be achieved by identifying
a completely different algorithm for the underlying process.  By
comparison, the choice of implementation language rates to make only
relatively modest impact.  It's often cheaper to throw CPU power at
the problem, rather than spend valuable wetware resources on trying to
optimise code.

A cautionary tale: I saw a laboriously hand-optimised assembler
program beaten by the same algorithm written in FORTRAN.  It turned
out that the optimising compiler knew more about the machine
architecture (in particular, its data interleaving properties) than
the well-intentioned but misguided hand-coder.  Guess which version
had been easier to write, cost less, had fewer typos, was easier to
maintain?

cheers



------------------------------

Date: Sun, 9 Jul 2000 01:41:05 +0200
From: "Brendon Caligari" <bcaligari@shipreg.com>
Subject: Re: Beyond perl? Need advice...
Message-Id: <8k8dj4$127$1@news.news-service.com>

"Philip Rennert" <phil.rennert@ioip.com> wrote in message
news:3967467A.C5C60EF@ioip.com...
> Hi,
>     I do machine learning, and I've coded up and used a lot of machine
> learning algorithms in Perl, because once you've used it, why do you
> want to use anything else?  In the business world, however, the attitude
> is:
> "You've coded & tested in Perl?  Good, you have a working prototype.
> Now write the real system."
> There may be a need to speed up and scale up my code.  What
> languages/platforms are best for doing this (and what kind of
> speed/scale improvement can be expected)?  The application will be
> smallish server code operating on largish data called by numerous
> clients.  I don't have a good feel for whether my Perl code is good
> enough, or what to rewrite it in, but unless I can make a case, I'll
> have to rewrite in Java (ugh), because it's perceived as
> fast/stable/good and Perl is not.
>     Any advice?  Please respond also by email to phil.rennert@ioip.com.
> TIA.
>

In the business world, as in physics, everything is relative.  In fact,
we have a term for this crap...called "Business Decisions".  (ie, things
that have to be accepted, never challenged, as they are coming
from people who are businessly gifted.....especially managers by
right of birth, etc)
If your boss is happy to pay you for doing in C what is already perfectly
working in perl, why should you loose any sleep over it?  If you want
to learn Java...do it in Java...if you want to get used to developing
in MS-FooBar do it in MS-FooBar :)








------------------------------

Date: Sun, 9 Jul 2000 09:21:22 +0100
From: "B Kemp" <hyagillot@tesco.net>
Subject: Re: Beyond perl? Need advice...
Message-Id: <8k9ct8$8di$1@barcode.tesco.net>

<SNIP>
>"You've coded & tested in Perl?  Good, you have a working prototype.
>Now write the real system."
>There may be a need to speed up and scale up my code.
<SNIP>

There MAY BE a need?
Do business managers work out how many months it might take to get a few
milliseconds off the time it takes to run?

Fast development time is what you need when the business managers keep on
changing their minds.




------------------------------

Date: Mon, 10 Jul 2000 15:17:58 +0100
From: "Joe_Broz@transarc.com" <jbroz@transarc.com>
Subject: Re: Beyond perl? Need advice...
Message-Id: <3969DB16.7F8CF539@transarc.com>

Steve Leibel wrote:
> 
> In article <3967467A.C5C60EF@ioip.com>, Philip Rennert
> <phil.rennert@ioip.com> wrote:
> 
> > Hi,
> >     I do machine learning, and I've coded up and used a lot of machine
> > learning algorithms in Perl, because once you've used it, why do you
> > want to use anything else?
> 
> Get the right tool for the job.  Perl doesn't scale well for large
> development projects that need to be maintained over time.

This is not true in all cases. There is just no way to generalize. The
question should be whether or not perl is suitable for the job. Because the
system may be over 20K lines is not a reason not to use it.

If it's well-written and modular, done by people who know what they're
doing, "scale" shouldn't be a problem.

> The other problem with Perl for large commercial systems is that it's too
> easy for inexperienced programmers to make a mess.

This is true no matter what language is used.

> next ten years.  Maintainability becomes more important in the long run
> than quick initial development.
> 
> Now if you can write organized maintainable Perl code that argument goes
> away, but then what about the next generation of maintenance programmers?

Maintainable code is maintanable code, no matter what language it's written
in. If, later on, you have only Java experts to maintain a system written
in perl there will be problems.

> One rule of thumb is that Perl is suitable for a one-person project of
> less than, say, 10 or 20 thousand lines of code, as long as you write
> clean modular code.  Past that point, Perl becomes quite unwieldy.  For

Whether it's unwieldy or not depends entirely on how it's written.


------------------------------

Date: Mon, 10 Jul 2000 09:47:01 -0400
From: Philip Rennert <phil.rennert@ioip.com>
Subject: Re: Beyond perl? Need advice...
Message-Id: <3969D3D5.72F152E0@ioip.com>

Hi,
    Thanks everyone, for your advice.  I realize my understanding of some of
the issues is limited, and apologize for the lack of definition.  I think
the upshot is that I should continue happily writing Perl for the moment,
and face the porting decision later when things are better known.
    My management is actually quite sensible and willing to listen.  They
tell me it's a harder sell, to people outside the company, to say "We have a
system written in Perl" compared to "..in Java".  Should it be?  From what
you're telling me, the answer is: "It depends...".

    Thanks again for sharing the benefit of your expertise,

        Phil





------------------------------

Date: 6 Jul 2000 23:39:06 GMT
From: Jeff Lacki <jeep@waltz.rahul.net>
Subject: bit-wise subroutines
Message-Id: <8k35aq$q8$1@samba.rahul.net>

Im looking for any subroutines which will (properly)
get/set bitmasks etc.

Anyone know of a module that already does this or where
I might look for some working code?

Thanks



------------------------------

Date: Fri, 07 Jul 2000 04:21:51 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: bit-wise subroutines
Message-Id: <39655B22.895828C3@rochester.rr.com>

Jeff Lacki wrote:
> 
> Im looking for any subroutines which will (properly)
> get/set bitmasks etc.
> 
> Anyone know of a module that already does this or where
> I might look for some working code?
 ...

Assuming the | & ^ and ~ operators are not sufficient for your purposes,
see

   perldoc -f vec

and also Bit::Vector and Math::MatrixBool.

-- 
Bob Walton


------------------------------

Date: Tue, 04 Jul 2000 14:10:52 GMT
From: "Harri Havanka" <havanka.harri@nokia.com>
Subject: Bizarre copy of HASH
Message-Id: <Mfm85.5851$oL4.119036@news2.nokia.com>

Hi, I'm quite new to Perl, and get following error:

Bizarre copy of HASH in leave at myscript.pl line 887

that line is:

@tmpArray = keys %{%{$refXmlHash}};

I debugged that, and noticed that refXmlHash is defined but it doesn't
contain anything, so I need to do some
simple IF-statement to test if $refXmlHash contain something.

So, can someone help me, please?





------------------------------

Date: Tue, 04 Jul 2000 14:33:11 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Bizarre copy of HASH
Message-Id: <7ar99a3qzb.fsf@merlin.hyperchip.com>


"Harri Havanka" <havanka.harri@nokia.com> writes:

> Hi, I'm quite new to Perl, and get following error:
> 
> Bizarre copy of HASH in leave at myscript.pl line 887
> 
> that line is:
> 
> @tmpArray = keys %{%{$refXmlHash}};

This should be enough:

	@tmpArray = keys %$refXmlHash;

> I debugged that, and noticed that refXmlHash is defined but it doesn't
> contain anything, so I need to do some
> simple IF-statement to test if $refXmlHash contain something.
> 
> So, can someone help me, please?

Checkout the docs for ref() in perlfunc:

	if (ref($refXmlHash) eq 'HASH') {
		....
	}


--Ala


------------------------------

Date: 7 Jul 2000 16:15:41 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Bizarre copy of HASH
Message-Id: <8k4vnd$met$1@pegasus.csx.cam.ac.uk>

Ala Qumsieh  <aqumsieh@hyperchip.com> wrote:
>
>Checkout the docs for ref() in perlfunc:
>
>	if (ref($refXmlHash) eq 'HASH') {
>		....
>	}

Or if you need to allow for the possibility of blessed references,
you may want

        if ($refXmlHash && UNIVERSAL::isa($refXmlHash, 'HASH')) {


Mike Guy


------------------------------

Date: Thu, 06 Jul 2000 14:32:03 +0200
From: Hajo Wuellner <Hajo.Wuellner@ascad.de>
Subject: blocking read with sockets
Message-Id: <39647C43.78A973BC@ascad.de>

Hi there,

I have a problem to implement code for blocked reading from a socket.
I have a server that receives data and should wait (block) until there
is new data from the client.
I tried 
	$client->recv($data,$MAXLEN,0);
but that doesn't block.

Then I tried IO::Select added the client-socket and called the select method.
	$select=IO::Select->new();
	$select->add($client);
	$select->can_read(10) ( timeout 10 seconds)
and
	$select->can_read(undef) (documented as: block until data is available)
but the commands return immediately.

I tried the 'raw' select command  (not from IO::Select) but this does not work
either.

Isn't it possible to do blocking reads with send and recv or what have I done
wrong.
-- 
Thanks in advance,
Hajo


------------------------------

Date: Mon, 10 Jul 2000 11:48:11 +0100
From: Alun Moon <alun.moon@ncl.ac.uk>
Subject: Byte compiling ... (got lost in perldocs and CTAN)
Message-Id: <3969A9EB.7A78A03E@ncl.ac.uk>

This may be clear in the FAQ and CTAN somewhere, but I've got a little lost 
digging around.

(We're using Perl 5.005_03, on a Sun Solaris)
I have some scripts that we'd like to send out to people to try, but the boss
is concerned about just giving them the source code...  

What I'd like to do is byte compile the scripts, so we can send them out.
This should keep the boss pacified enough.

I've found references to Malcom Beattie's backend, is it the
	perl -MO=Bytecompile,-ofile sourcescript
thingie...

Once I have the byte code how would I run it?

should I be using undump somewhere?

many thanks

Dr Alun Moon
(lost in the commercial world)


------------------------------

Date: Mon, 10 Jul 2000 08:16:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Byte compiling ... (got lost in perldocs and CTAN)
Message-Id: <slrn8mjfk9.tf8.tadmc@magna.metronet.com>

On Mon, 10 Jul 2000 11:48:11 +0100, Alun Moon <alun.moon@ncl.ac.uk> wrote:
>This may be clear in the FAQ and CTAN somewhere, but I've got a little lost 
>digging around.
>
>(We're using Perl 5.005_03, on a Sun Solaris)
>I have some scripts that we'd like to send out to people to try, but the boss
>is concerned about just giving them the source code...  


Then he should put an appropriate license on the code.


>What I'd like to do is byte compile the scripts, so we can send them out.
>This should keep the boss pacified enough.


   perldoc -q hide


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 7 Jul 2000 09:37:03 -0400
From: "James M Kupernik" <kupernik@bcn.net>
Subject: Calculating Taxes
Message-Id: <smbnd62gnu113@corp.supernews.com>

I'm trying to calculate the taxes on an order form, but I need to make sure
that the tax only shows up with two decimal points, not four. Thanks for any
help  you can provide.

James




------------------------------

Date: Fri, 07 Jul 2000 13:50:48 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Calculating Taxes
Message-Id: <slrn8mbnp8.9rf.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 7 Jul 2000 09:37:03 -0400, James M Kupernik <kupernik@bcn.net> wrote:
>I'm trying to calculate the taxes on an order form, but I need to make sure
>that the tax only shows up with two decimal points, not four. Thanks for any
>help  you can provide.

perldoc -f sprintf

Bernard
--
perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'


------------------------------

Date: Fri, 07 Jul 2000 09:45:39 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Calculating Taxes
Message-Id: <3965DF03.CD964515@attglobal.net>

James M Kupernik wrote:
> 
> I'm trying to calculate the taxes on an order form, but I need to make sure
> that the tax only shows up with two decimal points, not four. Thanks for any
> help  you can provide.
> 
> James


Try out the documentation for sprintf and/or printf

$ perldoc -f printf
$ perldoc -f sprintf

or for the web inclined:

http://www.perl.com/pub/doc/manual/html/pod/perlfunc/printf.html
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/sprintf.html


------------------------------

Date: Fri, 07 Jul 2000 08:49:18 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Calculating Taxes
Message-Id: <3965DFDE.B5F05DDF@texas.net>

James M Kupernik wrote:
> 
> I'm trying to calculate the taxes on an order form, but I need to make sure
> that the tax only shows up with two decimal points, not four. Thanks for any
> help  you can provide.

The answers to 99% of your Perl questions are as close as your
harddrive.

perldoc -q round

Make sure that you read the paragraph that begins:

"Rounding in financial applications can have serious implications"

carefully.

Then, read:

perldoc perldoc
perldoc perl

- Tom


------------------------------

Date: Fri, 07 Jul 2000 15:05:02 +0000
From: "Paul Taylor" <pap@sotonians.org.uk>
Subject: Re: Calculating Taxes
Message-Id: <2vl95.685$47.71906@nnrp4.clara.net>

You might want to use the sprintf statement here.  It is documented under

perldoc perlfunc

sprintf will allow you to format your data in the way that you want.
Something like the following will do the trick.

$goods = 15.48
$taxRate = 0.175

$valueAddedTax = $goods * $taxRate ;

# the %f specifies the scalar should be displayed as a float
# the 4.2 between the % and the f specify that four ( or less )
# digits before the decimal point and 2 digits after the 
# decimal point.

# Perl will 'round up' where appropriate.  A brief demo
# 18.755 will be rounded to 18.75
# 18.7550001 will be rounded to 18.76

$valueAddedTax = sprintf( "%4.2f", $valueAddedTax ) ;

The new value of $valueAddedTax should be formatted as required.

Regards,

Pap.
In article <smbnd62gnu113@corp.supernews.com>, "James M Kupernik"
<kupernik@bcn.net> wrote:
> I'm trying to calculate the taxes on an order form, but I need to make
> sure that the tax only shows up with two decimal points, not four.
> Thanks for any help  you can provide.
> 
> James
> 
> 




------------------------------

Date: Sat, 08 Jul 2000 03:17:04 GMT
From: "Kevin M. Sproule" <kmsproule@worldnet.att.net>
Subject: Re: Calculating Taxes
Message-Id: <Q2x95.507$%P.32381@bgtnsc06-news.ops.worldnet.att.net>


"James M Kupernik" <kupernik@bcn.net> wrote in message
news:smbnd62gnu113@corp.supernews.com...
> I'm trying to calculate the taxes on an order form, but I need to make
sure
> that the tax only shows up with two decimal points, not four. Thanks for
any
> help  you can provide.
>
> James
>
>
James,

Apart from the rounding issue be carefull to calculate the taxes correctly.
The tax should be calculated on the total amount of the taxable items.  Do
not calculate tax on each item individually.  Doing this and rounding each
result will cause you incorrectly figure the tax.  A sales tax audit could
cost you dearly if you do a large volume of taxable items.

Example:

Tax Rate 0.0670

Items         Tax (wrong)
    2.27      0.15
    1.98      0.13
   10.34      0.69
  123.45      8.27
   12.34      0.83
    0.75      0.05
    0.97      0.06
=========    =====
  152.10     10.18   Tax should be: 152.10 * 0.0670 = 10.19

A simple Perl rounding function could be:

$tax_amount = int(($total_taxable * $tax_rate + .005) * 100) / 100;

Yours truly,

Kevin Sproule






------------------------------

Date: Fri, 7 Jul 2000 23:07:04 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Calculating Taxes
Message-Id: <slrn8md6mo.n64.tadmc@magna.metronet.com>

On Sat, 08 Jul 2000 03:17:04 GMT, Kevin M. Sproule <kmsproule@worldnet.att.net> wrote:
>
>"James M Kupernik" <kupernik@bcn.net> wrote in message
>news:smbnd62gnu113@corp.supernews.com...

>> I'm trying to calculate the taxes on an order form

>Apart from the rounding issue be carefull to calculate the taxes correctly.


Apart from the rounding and calculation issues, be careful to
avoid accuracy and precision concerns as much as practical...


>  152.10     10.18   Tax should be: 152.10 * 0.0670 = 10.19
   ^^^^^^


 ... by working with integers (cents) instead of floating
point (dollars).

Convert to dollars only at the very end of processing.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 8 Jul 2000 14:36:39 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Calculating Taxes
Message-Id: <8k7ap7$q6f$1@orpheus.gellyfish.com>

On Fri, 7 Jul 2000 23:07:04 -0400 Tad McClellan wrote:
> On Sat, 08 Jul 2000 03:17:04 GMT, Kevin M. Sproule <kmsproule@worldnet.att.net> wrote:
>>
>>"James M Kupernik" <kupernik@bcn.net> wrote in message
>>news:smbnd62gnu113@corp.supernews.com...
> 
>>> I'm trying to calculate the taxes on an order form
> 
>>Apart from the rounding issue be carefull to calculate the taxes correctly.
> 
> 
> Apart from the rounding and calculation issues, be careful to
> avoid accuracy and precision concerns as much as practical...
> 
> 
>>  152.10     10.18   Tax should be: 152.10 * 0.0670 = 10.19
>    ^^^^^^
> 
> 
> ... by working with integers (cents) instead of floating
> point (dollars).
> 
> Convert to dollars only at the very end of processing.
> 

and some truly paranoid people will do this as a string operation rather
than by division ;-}

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


------------------------------

Date: 10 Jul 2000 16:55:36 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Calling another perl CGI
Message-Id: <20000710125536.04376.00003587@ng-ct1.aol.com>

I'm using a perl program to process a form, what I want to do is have my perl
program redirect the form input to another perl program (if certain criterea
are met). I know all of that of course, but what I need to know is how do I
call or switch to another perl program from inside the first one. Thanks in
advance for anyone giving me some assistance on solving this baffling problem.


------------------------------

Date: Mon, 10 Jul 2000 18:23:00 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Calling another perl CGI
Message-Id: <396A14C9.29F7757F@rochester.rr.com>

Jimtaylor5 wrote:
> 
> I'm using a perl program to process a form, what I want to do is have my perl
> program redirect the form input to another perl program (if certain criterea
> are met). I know all of that of course, but what I need to know is how do I
> call or switch to another perl program from inside the first one.
 ...
Well, you could use "exec".  perldoc -f exec .  You would have to
arrange a scheme to pass whatever data you need to pass to the second
program.  Maybe you could slurp the second program into a string and
then "eval" that string.  That might simplify the data transfer problem
since all the global variables from the first program would still be
available.  Finally, if the "form" you are talking about is an HTML form
and your program is a CGI program, maybe you could do a redirect to your
second program.  See HTML, HTTP, or CGI documentation for how to do
that, since it isn't a Perl question.
-- 
Bob Walton


------------------------------

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 3550
**************************************


home help back first fref pref prev next nref lref last post