[8232] in Perl-Users-Digest
Perl-Users Digest, Issue: 1851 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 10 18:07:53 1998
Date: Tue, 10 Feb 98 15:01:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 10 Feb 1998 Volume: 8 Number: 1851
Today's topics:
Rounding Off Decimal Numbers <chrisw@solarcomm.com>
Re: Rounding Off Decimal Numbers <lach@lach.net>
Re: strange split behaviour <rootbeer@teleport.com>
Re: substitution/expression (Craig Berry)
Re: Syntax-coloring editor for NT <mike@ns.minivend.com>
Re: SYSTEM command - How do you return data to the brow (Craig Berry)
Re: SYSTEM command - How do you return data to the brow <westxga@ptsc.slg.eds.com>
Re: To All Perl Guru's (Craig Berry)
Re: To All Perl Guru's <tchrist@mox.perl.com>
Re: To All Perl Guru's <cberry@cinenet.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Feb 1998 15:45:54 +0000
From: Chris Wicklas <chrisw@solarcomm.com>
Subject: Rounding Off Decimal Numbers
Message-Id: <34E0762F.20A4@solarcomm.com>
Hi all-
I was wondering if someone could give me a hand. I've been trying to get
a decimal number such as 57.788 to come out as 57.79. I'm having a hard
time getting this to work. It's for a shopping cart that I'm working on
and I can't get the final price to come out rounded off after the tax,
which ususally ends up being some mega-digited number, is added in.
I've tried using the Floating-Point Math Package, but with no luck. I'm
just learning Perl now and got stuck on this point. Any help that anyone
could offer would be greatly appreciated.
Thanks in advance-
Chris
--
Chris Wicklas
Web Development
Solar Communications
1120 Frontenac Road
Naperville, IL 60563
Email: chrisw@solarcomm.com
Phone: 630-983-1400 x2025
Fax: 630-983-1095
------------------------------
Date: Tue, 10 Feb 1998 22:31:21 -0600
From: Lachlan Dunlop <lach@lach.net>
Subject: Re: Rounding Off Decimal Numbers
Message-Id: <34E12999.60B99EE5@lach.net>
Chris,
how about... printf("%8.2f", $value);
or
$value = sprintf("%8.2f", $value);
Later
Lach
Chris Wicklas wrote:
> Hi all-
>
> I was wondering if someone could give me a hand. I've been trying to get
> a decimal number such as 57.788 to come out as 57.79. I'm having a hard
> time getting this to work. It's for a shopping cart that I'm working on
> and I can't get the final price to come out rounded off after the tax,
> which ususally ends up being some mega-digited number, is added in.
>
> I've tried using the Floating-Point Math Package, but with no luck. I'm
> just learning Perl now and got stuck on this point. Any help that anyone
> could offer would be greatly appreciated.
>
> Thanks in advance-
> Chris
> --
>
> Chris Wicklas
> Web Development
>
> Solar Communications
> 1120 Frontenac Road
> Naperville, IL 60563
>
> Email: chrisw@solarcomm.com
> Phone: 630-983-1400 x2025
> Fax: 630-983-1095
------------------------------
Date: Tue, 10 Feb 1998 12:59:21 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Andreas Hartmann <ahartman@geolin5.geophys2.uni-bremen.de>
Subject: Re: strange split behaviour
Message-Id: <Pine.GSO.3.96.980210125804.26052T-100000@user2.teleport.com>
On 10 Feb 1998, Andreas Hartmann wrote:
> $n=split;
Did you mean to use split in a scalar context? That's discouraged.
> Is this a bug or did I miss something? I got no serious errors
> when I compiled the source.
Did you use -w when you ran your program? :-) Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 10 Feb 1998 21:05:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: substitution/expression
Message-Id: <6bqfe0$he5$2@marina.cinenet.net>
R. Allen Conway (raconway@atos-group.com) wrote:
: One way of doing it is ...
:
: $field =~ s/([ \/])([a-z]/$1.uc($2)/eg;
^ Missing ) before /
Even easier is:
$field =~ s!([ /][a-z])!\U$1!g;
Hope this helps!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 10 Feb 1998 21:04:15 GMT
From: Mike Heins <mike@ns.minivend.com>
Subject: Re: Syntax-coloring editor for NT
Message-Id: <6bqfcf$629$1@ocoee.iac.net>
scott@softbase.com wrote:
> Interesting diatribe:
>> Buying proprietary software is almost understandable when a free
>> equivalent is not available, but paying $100 for a text editor is
>> ridiculous. As long as people like you keep buying their crap,
>> people like Microsoft will continue to screw the rest of us.
> Microsoft is not "screwing the rest of us". Remember the free market,
> the thing that makes the economy run? If there's demand, a product will
> be viable.
Here I agree, for sure. I may not like Microsoft, but apparently a lot
of people do.
> That is the flaw in free software: it ignores the fact that you have to
> eat. And provide for all other necessities. Some of us even want
> creature comforts occasionally. The free software stuff sounds
> wonderful, but the GNU Manifesto and all that stuff was written by
> ivory tower academics with tenure or some other source of inexhaustible
> income who have no clue about what living in the real world is like.
> How you have to have a job and things like that. Free software is
> written in ivory towers.
Here I must disagree. Free software has been around long enough
to see its relationship to the world.
Free software is supported in large part by corporations who support
those academics. Those "ivory tower" people only get the freedom to
pursue this "inexhaustible income" as long as they generate the grants to
support their programs. The minute that dries up, it's back to teaching
3 and 2 and talking about the good old days.
A fair proportion of free software is written by people who do it to gain
experience. As a result, many programs were started by and flourished
under the care of grad students. I would hardly call that the ivory tower.
Did you know that a good percentage of free software was done by users
and developers who found nothing appropriate for what they were doing? By
just regular people. Witness Perl.
Some free software was produced by large companies! Their researchers
did something significant, but they had no place to exploit it. So they
get permission to give it away. Unix, for example. Though official title
to it stayed with AT&T for many years, they really gave it to the world.
Some of these programs go nowhere, and die. Some take on some life --
often the author goes on to other things, and someone else starts
maintaining it. Sometimes the program becomes the basis for a small
business, as mine has. And very rarely it becomes a pretty big business,
as with Sun and Netscape. Who then make the grants so that more free
software can be developed and sprout anew. So the circle is complete.
> What if *no* commercial development took
> place? Can you imagine the stagnation of software in general? Home
> computing would still not exist. Computers would still be locked in
> ivory towers. The only software would be tools to create more software
> (like UNIX) and a few programs like typesetters and Mathematica which
> help create research papers. The only people using computers would
> be academics.
I agree that we need commercial development. There are quite a few areas
(examples might be financial systems, medical software, high-end database
software) where resources must be marshaled in a more structured way
than free software permits.
And as much as the people here (including me) dislike Microsoft software,
it has given some competition to the freeware. It is now usual for
freeware programs to install without editing files, which has made
freeware viable for more users. We can thank Microsoft (and of course
Apple) for that.
I think we live in interesting times. It is fun to be involved in free
software, which is seriously challenging for-pay software in many areas.
I don't pretend to know how it will all pan out -- I am just going to enjoy
the vitality of the market.
Regards,
Mike Heins http://www.minivend.com/ ___
Internet Robotics |_ _|____
"The U.S. Senate -- white 131 Willow Lane, Floor 2 | || _ \
male millionaires working Oxford, OH 45056 | || |_) |
for YOU!" -- Dave Barry <mikeh@minivend.com> |___| _ <
513.523.7621 FAX 7501 |_| \_\
------------------------------
Date: 10 Feb 1998 21:10:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: SYSTEM command - How do you return data to the browser?
Message-Id: <6bqfob$he5$3@marina.cinenet.net>
Rick Ryan (rickryan@datrixnet.com) wrote:
: I'm using the SYSTEM command to run an external .exe file on my NT server.
: Is there any way to have the output of the called program return directly to
: the browser or back to my perl script? I've tried it several different ways
: and the only thing I can get to work is to write the information back to a
: file, then use the perl script to open and read the contents of that file.
Don't know if this works under NT, but the standard way to get command
output back into the Perl app is to use backticks or qx, like so:
my @fooOutput = `/usr/bin/foo -v -n -x 42`;
my @barOutput = qx(/opt/gnu/bin/bar --annoying_long_arg=27);
The command output gets stored line by line into the lists.
Hope this helps!
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 10 Feb 1998 16:30:15 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: SYSTEM command - How do you return data to the browser?
Message-Id: <34E08096.5F8D@ptsc.slg.eds.com>
Rick Ryan wrote:
>
> I'm using the SYSTEM command to run an external .exe file on my NT server.
> Is there any way to have the output of the called program return directly to
> the browser or back to my perl script? I've tried it several different ways
> and the only thing I can get to work is to write the information back to a
> file, then use the perl script to open and read the contents of that file.
>
> Any help is appreciated.
>
open(FH, "some_pgm.exe|");
while (<FH>) {
------------------------------
Date: 10 Feb 1998 21:50:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: To All Perl Guru's
Message-Id: <6bqi3h$he5$5@marina.cinenet.net>
James L. Taylor (cowboy@cnnw.net) wrote:
: OK OK already.....I am totally new to perl and know nothing and then I
: read these posts here about doing work offline and I figured it could
: be done so instead of sitting here wondering how to do this I ask, and
: then when I asked I get insulted that I'm an AOL idiot or no one takes
: the time to just say "This isn't possible". Jeez folks give a newbie a
: break.
Hey, deep breath! Who said it was impossible? You can write Perl code
offline, for any definition of 'offline' short of 'dead' (probably). I
write Perl code in my head (often at inappropriate moments), I've jotted
down bits and pieces in notebooks, I've written Perl fragments in mail
programs on machines without Perl installed (to send them to other
people), and so forth.
If (as seems likely) you are using 'offline' to mean 'on a computer which
has Perl installed but is not connected to the net', and 'doing work' to
mean 'running Perl programs', then the answer is still yes. In fact, I
(and many others here) don't use Perl primarily as a net tool, but rather
as a shell scripting language and metatool for implementing 'little
languages'. The only net I care about while I'm doing that is local
NFS...which means I'm productive about a third of the time. :)
Even if you intend 'doing work' to mean 'running Perl programs intended
for net use' (e.g., CGI apps), the answer is *still* yes. I routinely do
all my preliminary CGI testing locally before moving anything onto the
server. CGI.pm is helpful in this regard, as it notices when it's being
run 'offline' and lets you hand-enter pseudo-form data.
Make better sense, now?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 10 Feb 1998 22:06:37 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: To All Perl Guru's
Message-Id: <6bqj1d$23v$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, cberry@cinenet.net (Craig Berry) writes:
:net use (e.g., CGI apps),
I do get nervous when I hear people confuse Networking with
TCP with HTTP with WWW with CGI with .... See what I mean?
I'm sure you didn't say that (yes, "i.e." ne "e.g."), but many
don't understand the difference.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Randal said it would be tough to do in sed. He didn't say he didn't
understand sed. Randal understands sed quite well. Which is why he
uses Perl. :-) -- Larry Wall in <7874@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 10 Feb 1998 14:21:06 -0800
From: Craig Berry <cberry@cinenet.net>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: To All Perl Guru's
Message-Id: <Pine.GSO.3.95.980210140739.14798A-100000@hollywood.cinenet.net>
On Tue, 10 Feb 1998, Tom Christiansen wrote:
> In comp.lang.perl.misc, cberry@cinenet.net (Craig Berry) writes:
> :net use (e.g., CGI apps),
>
> I do get nervous when I hear people confuse Networking with
> TCP with HTTP with WWW with CGI with .... See what I mean?
> I'm sure you didn't say that (yes, "i.e." ne "e.g."), but many
> don't understand the difference.
To me, it's one of those tricky learning-curve issues. For newbies,
thinking 'net code' is semantically equivalent to 'CGI code' may be a
useful approximation, just as thinking (for example) 'the Civil War was
about slavery' is a useful approximation for 8 year olds. It avoids
getting into a whole rat's nest of issues which will probably go right
over a newbie's head, and lets said newbie get some useful work done
before hitting the underlying, more complex reality.
The counter-argument, of course, is that teaching not-quite-true
simplifications requires 'unlearning' to occur when the more complex truth
becomes necessary. My personal comfort point on this issue is to make
clear once or twice that I'm not talking about the whole picture (as in my
use of e.g. rather than i.e.), then proceed with the simplified view. If
someone catches the aside and inquires about it, they're probably ready
for the big picture.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 1851
**************************************