[30791] in Perl-Users-Digest
Perl-Users Digest, Issue: 2036 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 5 14:09:59 2008
Date: Fri, 5 Dec 2008 11:09:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 5 Dec 2008 Volume: 11 Number: 2036
Today's topics:
Re: a homework need help <cwilbur@chromatico.net>
Re: a homework need help <tzz@lifelogs.com>
Endless loop instead of die... delfin_soft@homoludens.elte.hu
Re: how detect english subject and predicate in a sente <RedGrittyBrick@spamweary.invalid>
Re: how detect english subject and predicate in a sente <tzz@lifelogs.com>
How to use IO::Socket with Log::Agent ad Log::Fork <doug.farrell@gmail.com>
Re: How to use IO::Socket with Log::Agent ad Log::Fork <smallpond@juno.com>
Re: How to use IO::Socket with Log::Agent ad Log::Fork <tzz@lifelogs.com>
Re: Invalid Argument while Opening file <smallpond@juno.com>
Re: Invalid Argument while Opening file (Randal L. Schwartz)
Re: Invalid Argument while Opening file xhoster@gmail.com
Re: Mathematica 7 compares to other languages <xahlee@gmail.com>
PDF::Reuse and number rounding/precision <justin.0810@purestblue.com>
Re: PDF::Reuse and number rounding/precision <bugbear@trim_papermule.co.uk_trim>
Re: PDF::Reuse and number rounding/precision <r.ted.byers@gmail.com>
Re: PDF::Reuse and number rounding/precision <glex_no-spam@qwest-spam-no.invalid>
Re: PDF::Reuse and number rounding/precision <r.ted.byers@gmail.com>
Re: sysread and syswrite analogy xhoster@gmail.com
Re: Why would it appear to my scripts that a server the <r.ted.byers@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 05 Dec 2008 11:22:55 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: a homework need help
Message-Id: <867i6e7fs0.fsf@mithril.chromatico.net>
>>>>> "JM" == Josef Moellers <josef.moellers@fujitsu-siemens.com> writes:
JM> As Tim Greer has pointed out: we don't do other people's
JM> homework,
Oh, but we do -- just not in any sort of useful way.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Fri, 05 Dec 2008 10:43:06 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: a homework need help
Message-Id: <86ljuulgit.fsf@lifelogs.com>
On Thu, 4 Dec 2008 16:38:52 -0800 "Camel" <jiao_he@sbcglobal.net> wrote:
C> I have no clue with my homework, can anyone help me?
C> Three digits "1,2,3", how many 3-digit numbers can be made? print all the
C> numbers
C> I know how to calculate the total numbers and using loop to print all the
C> numbers. The problem is how to write a generic program that takes any number
C> of digits. For example, if given "1,2,3,4,5" digits, you still can use your
C> program to print all the combinations of 5-digit numbers without modifing
C> it.
I'll give you a hint: if you need the combinations of N digits, you can
generate them with the combinations of N-1 digits. Print out the list
of 1-digit numbers and compare it to the list of 2-digit and 3-digit
numbers and you'll see what I mean.
0 1 2 3 4 5 6 7 8 9
compare to:
00 01 02 03 04 ... 09
10 11 12 13 14 ... 19
...
90 91 92 93 94 ... 99
and then
000 001 002 003 004 ... 099
100 101 102 103 104 ... 199
...
900 901 902 903 904 ... 999
Do you see the pattern? It should be obvious by now.
Ted
------------------------------
Date: 5 Dec 2008 19:48:37 +0100
From: delfin_soft@homoludens.elte.hu
Subject: Endless loop instead of die...
Message-Id: <XHWjhhFZNFQE@ludens>
Hi all!
My problem is: Why the following code does not die and remains in an endless
loop . But if I remove one of the lines, the endless loop disappears.
On 'This is perl, v5.8.8 built for i486-linux-gnu-thread-multi'
or on 'This is perl, v5.8.4 built for i386-linux-thread-multi'
But for example it does die normally on
'This is perl, v5.6.1 built for VMS_AXP'
#---code
#!/usr/bin/perl
use warnings;
our @ISA=('loop');
$SIG{__WARN__}=sub {eval 'no warnings';};
eval("(bless {},'main')->loop");
print "loop died: $@\n";
#---end_of_code
Thanks a lot,
Bye delfin...
------------------------------
Date: Fri, 05 Dec 2008 15:34:43 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: how detect english subject and predicate in a sentence
Message-Id: <49394a13$0$2527$da0feed9@news.zen.co.uk>
Tim Greer wrote:
> Randal L. Schwartz wrote:
>
>> (2) Fruit has aerodynamics that are similar to bananas.
>
> I actually read it like that, genuinely. "Fruit" flies like a banana.
> I'd have thought differently if it was phrased: "Fruit flies" like
> bananas.
I'd find that odd. Since fruit is a well-known adjective for the noun
flies, I'd wonder if the quote marks were intended to convey irony. I
think it may only be the previous sentence that conditioned you to
interpret the second sentence in that particular way. It is often
presented as a garden path sentence -- in that it deliberately misleads.
--
RGB
The horse raced past the barn fell.
The car driven past the barn crashed.
The old man the boat.
The man whistling tunes pianos.
The cotton clothing is made of grows in Mississippi.
- Wikipedia.
------------------------------
Date: Fri, 05 Dec 2008 10:34:53 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: how detect english subject and predicate in a sentence
Message-Id: <86prk6lgwi.fsf@lifelogs.com>
On Thu, 04 Dec 2008 18:09:08 -0800 merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>>>>>> "Charlton" == Charlton Wilbur <cwilbur@chromatico.net> writes:
Charlton> Consider: "Time flies like an arrow. Fruit flies like a banana."
RLS> Keep in mind, the second sentence has *three* interesting interpretations:
RLS> (1) There are a kind of flies, called "fruit flies" that are attracted
RLS> to bananas.
RLS> (2) Fruit has aerodynamics that are similar to bananas.
RLS> (3) You are instructed to attack some flies by throwing fruit at them.
RLS> Do this as a banana might do it.
RLS> Granted, they have various levels of relative believability, but this
RLS> is not something you can simply regex.
I have a fourth interpretation, but the margin is too small to write it
out here.
Ted
------------------------------
Date: Fri, 5 Dec 2008 08:38:04 -0800 (PST)
From: writeson <doug.farrell@gmail.com>
Subject: How to use IO::Socket with Log::Agent ad Log::Fork
Message-Id: <c398d13e-14aa-4861-9adf-d5062cc46be7@v4g2000yqa.googlegroups.com>
Hi all,
A vender supplied a large Perl program that uses the Log::Agent module
to log a great deal of information to rotated files. Right now I have
a program that parses these log files periodically to change the state
of our systems based on what the Perl program is doing. This is
awkward and problematic for me, and I'd like to do something
different. What I'd like to do is have the Log::Agent module not only
log the messages to a file, but send them to a server (which I would
write) over the network using IO::Socket. This looks like it would
work as Log::Agent support IO::Handle and IO::Socket is derived from
that. However, that's about as far as I've gotten as I'm not a Perl
programmer at all, though I am a programmer. Can anyone help me out
and point me in the right direction to do this kind of thing? Any
guidance would be appreciated!
Thanks,
Doug
------------------------------
Date: Fri, 5 Dec 2008 09:31:44 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: How to use IO::Socket with Log::Agent ad Log::Fork
Message-Id: <48c0b2cf-67cc-4e53-84b8-9c4b3eb2775b@e18g2000yqo.googlegroups.com>
On Dec 5, 11:38 am, writeson <doug.farr...@gmail.com> wrote:
> Hi all,
>
> A vender supplied a large Perl program that uses the Log::Agent module
> to log a great deal of information to rotated files. Right now I have
> a program that parses these log files periodically to change the state
> of our systems based on what the Perl program is doing. This is
> awkward and problematic for me, and I'd like to do something
> different. What I'd like to do is have the Log::Agent module not only
> log the messages to a file, but send them to a server (which I would
> write) over the network using IO::Socket. This looks like it would
> work as Log::Agent support IO::Handle and IO::Socket is derived from
> that. However, that's about as far as I've gotten as I'm not a Perl
> programmer at all, though I am a programmer. Can anyone help me out
> and point me in the right direction to do this kind of thing? Any
> guidance would be appreciated!
>
> Thanks,
> Doug
http://jobs.perl.org/
------------------------------
Date: Fri, 05 Dec 2008 11:52:47 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to use IO::Socket with Log::Agent ad Log::Fork
Message-Id: <86abbaldao.fsf@lifelogs.com>
On Fri, 5 Dec 2008 08:38:04 -0800 (PST) writeson <doug.farrell@gmail.com> wrote:
w> A vender supplied a large Perl program that uses the Log::Agent module
w> to log a great deal of information to rotated files. Right now I have
w> a program that parses these log files periodically to change the state
w> of our systems based on what the Perl program is doing. This is
w> awkward and problematic for me, and I'd like to do something
w> different. What I'd like to do is have the Log::Agent module not only
w> log the messages to a file, but send them to a server (which I would
w> write) over the network using IO::Socket. This looks like it would
w> work as Log::Agent support IO::Handle and IO::Socket is derived from
w> that. However, that's about as far as I've gotten as I'm not a Perl
w> programmer at all, though I am a programmer. Can anyone help me out
w> and point me in the right direction to do this kind of thing? Any
w> guidance would be appreciated!
1) find the places where the Log::Agent functions are used.
2) wrap those calls with your own log_custom() function
3) do whatever you need inside the log_custom() function
Sending arbitrary log data over the network can be slow, unreliable, and
difficult to implement. Consider using syslog's built-in log
aggregation features. Just writing out all log data to an open network
socket and hoping it will work, will not work.
Ted
------------------------------
Date: Fri, 5 Dec 2008 06:32:22 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Invalid Argument while Opening file
Message-Id: <ef856e43-4b36-410b-b99a-1840e267680c@j11g2000yqg.googlegroups.com>
On Dec 5, 6:23 am, Pradeep <bubunia2000s...@gmail.com> wrote:
> Hi all,
> When I was writing a code which will check some syntax of the files
> inside a directory. The first_pass proc gathers all the related
> variables and second_pass proc process those lines inside the file.
> When I ran the program it gave an error:
> Couldn't open input file "a.tcl": Invalid argument at C:/qtcheckref/
> checktclvars.pl line 268, <INFILE> line 13591.
>
> Could anyone help me in this regard?
> return $vars;
>
> close(INFILE);
>
How do you get to the close statement?
------------------------------
Date: Fri, 05 Dec 2008 07:24:22 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Pradeep <bubunia2000ster@gmail.com>
Subject: Re: Invalid Argument while Opening file
Message-Id: <86ej0m7ihl.fsf@blue.stonehenge.com>
>>>>> "Pradeep" == Pradeep <bubunia2000ster@gmail.com> writes:
Pradeep> my $array, $var, $temp, $key;
use strict and/or use warnings would have both caught this error.
Clearly, you're not using either, despite all the tutorials that
say to do so.
Why don't you start there, and when you fix everything they point out,
come back here?
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: 05 Dec 2008 17:17:34 GMT
From: xhoster@gmail.com
Subject: Re: Invalid Argument while Opening file
Message-Id: <20081205121632.293$1R@newsreader.com>
Pradeep <bubunia2000ster@gmail.com> wrote:
> Hi all,
> When I was writing a code which will check some syntax of the files
> inside a directory. The first_pass proc gathers all the related
> variables and second_pass proc process those lines inside the file.
> When I ran the program it gave an error:
> Couldn't open input file "a.tcl": Invalid argument at C:/qtcheckref/
> checktclvars.pl line 268, <INFILE> line 13591.
>
> Could anyone help me in this regard?
If you are going to post 235 lines of code (and not even have that code
be complete at 268 lines), which you really shouldn't do, then you should
at least tell us which of those lines corresponds to line 268 of your
original code.
> open(INFILE,"<$infile")
> || die "Couldn't open input file '$infile': $!";
If you accurately reported the error message, then the absence of literal
single quotes suggests that this is not line 268.
...
> open(INFILE,"<$infile")
> || die "Couldn't open input file $infile: $!";
If you accurately reported the error message, and if this is line 268,
then the value of the variable $infile seems to contain literal double
quotes in it, as if the name of the file included quote symbols. On
windows, this apparently is not allowed.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 5 Dec 2008 07:51:20 -0800 (PST)
From: Xah Lee <xahlee@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <f4ba3561-ebe7-44c2-a7a7-9a78cd1cc6a3@g1g2000pra.googlegroups.com>
On Dec 4, 6:09 pm, jason-s...@creativetrax.com wrote:
> For the interested, with MMA 6, on a Pentium 4 3.8Ghz:
>
> The code that Jon posted:
>
> Timing[Export["image-jon.pgm", Graphics@Raster@Main[2, 100, 4]]]
> {80.565, "image-jon.pgm"}
>
> The code that Xah posted:
>
> Timing[Export["image-xah.pgm", Graphics@Raster@Main[2, 100, 4.]]]
> {42.3186, "image-xah.pgm"}
>
> So Xah's code is about twice as fast as Jon's code, on my computer.
>
> The resulting files were identical (and both looked like pure white
> images; I thought they'd be interesting!).
The result is not pure white images. They are ray traced spheres
stacked in some recursive way. Here's the output in both my and jon's
version: http://xahlee.org/xx/image.pgm
also, note that Mathematica 6 has the function Normalize builtin,
which is used in Jon's code deeply in the core. Normalize is not in
Mathematica 4, so i had to code it myself, in this line: =E2=80=9Cnorm=3DFu=
nction
[#/Sqrt@(Plus@@(#^2))];=E2=80=9D. This possibly slow down my result a lot. =
You
might want to replace any call of =E2=80=9Cnorm=E2=80=9D in my program by t=
he builtin
Normalize.
Also, each version of Mathematica has more optimizations. So, that
might explain why on v4 the speed factor is ~0.2 on my machine while
in v6 you see ~0.5.
My machine is OS X 10.4.x, PPC G5 1.9 Ghz.
-------------------------
let me take the opportunity to explain some high powered construct of
Mathematica.
Let's say for example, we want to write a function that takes a vector
(of linear algebra), and return a vector in the same direction but
with length 1. In linear algebar terminology, the new vector is called
the =E2=80=9Cnormalized=E2=80=9D vector of the original.
For those of you who don't know linear algebra but knows coding, this
means, we want a function whose input is a list of 3 elements say
{x,y,z}, and output is also a list of 3 elements, say {a,b,c}, with
the condition that
a =3D x/Sqrt[x^2+y^2+z^2]
b =3D y/Sqrt[x^2+y^2+z^2]
c =3D z/Sqrt[x^2+y^2+z^2]
For much of the history of Mathematica, normalize is not a builtin
function. It was introduced in v6, released sometimes in 2007. See
bottom of:
http://reference.wolfram.com/mathematica/ref/Normalize.html
Now, suppose our task is to write this function. In my code, you see
it is:
norm=3DFunction[#/Sqrt@(Plus@@(#^2))];
let me explain how it is so succinct.
Mathematica's syntax support what's called FullForm, which is
basically a fully nested notation like lisp's. In fact, the
Mathematica compiler works with FullForm. The FullForm is not
something internal. A programer can type his code that way if he so
pleases.
in FullForm, the above expression is this:
Set[ norm, Function[ Times[Slot[1], Power[ Sqrt[ Apply[ Plus, Power
[ Slot[1], 2 ] ] ], -1 ] ] ]
Now, in this
norm=3DFunction[#/Sqrt@(Plus@@(#^2))]
The =E2=80=9CFunction=E2=80=9D is your lisper's =E2=80=9Clambda=E2=80=9D. T=
he =E2=80=9C#=E2=80=9D is the formal
parameter. So, in the outset we set =E2=80=9Cnorm=E2=80=9D to be a pure fun=
ction.
Now, note that the =E2=80=9C#=E2=80=9D is not just a number, but can be any=
argument,
including vector of the form {x,y,z}. So, we see here that math
operations are applied to list entities directly. For example, in
Mathematica, {3,4,5}/2 returns {3/2,2,5/2} and {3,4,5}^2 returns
{9,16,25}.
In typical lang such as python, including lisp, you would have to map
the operation into each lisp elements instead.
The =E2=80=9CSqrt@...=E2=80=9D is a syntax shortcut for =E2=80=9CSqrt[...]=
=E2=80=9D, and the
=E2=80=9CPlus@@...=E2=80=9D is a syntax shortcut for =E2=80=9CApply[Plus, .=
..]=E2=80=9D, which is
lisp's =E2=80=9Cfuncall=E2=80=9D. So, taking the above all together, the co=
de for
=E2=80=9Cnorm=E2=80=9D given above is _syntactically equivalent_ to this:
norm=3DFunction[ #/Sqrt[ Apply[Plus, #^2] ]]
this means, square the vector, add them together, take the square
root, then have the original vector divide it.
The =E2=80=9C#=E2=80=9D is in fact a syntax shortcut for =E2=80=9CSlot[1]=
=E2=80=9D, meaning the first
formal parameter. The =E2=80=9C=3D=E2=80=9D is in fact a syntax shortcut fo=
r =E2=80=9CSet[]=E2=80=9D.
The =E2=80=9C^=E2=80=9D is a shortcut for =E2=80=9CPower[]=E2=80=9D, and th=
e =E2=80=9C/=E2=80=9D is a shortcut for
=E2=80=9CPower[..., -1]=E2=80=9D. Putting all these today, you can see how =
the code is
syntactically equivalent to the above nested FullFolm.
Note, that the =E2=80=9Cnorm=E2=80=9D as defined above works for any diment=
ional
vectors, i.e. list of any length.
In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java,
you'll have 50 or hundreds lines.
For more detail on syntax, see:
=E2=80=A2 The Concepts and Confusions of Prefix, Infix, Postfix and Fully
Nested Notations
http://xahlee.org/UnixResource_dir/writ/notations.html
Xah
=E2=88=91 http://xahlee.org/
=E2=98=84
------------------------------
Date: Fri, 05 Dec 2008 14:02:43 -0000
From: Justin C <justin.0810@purestblue.com>
Subject: PDF::Reuse and number rounding/precision
Message-Id: <303e.49393483.5abf4@zem>
I'm using PDF::Reuse to produce output in a PDF template. The problems
I'm having are:
* I need to print currency values with two decimal places regardless of
whether the number has anything after the decimal point.
* I need to print values for weight with up to four digits after the
decimal point (if there are digits).
What PDF::Reuse is doing is only printing integars where there is
nothing after the decimal for my currency output, and printing fourteen
digits after the decimal in places where I need rounding.
I'm using the following to produce output:
prText($x, $y, $string)
$x and $y are horizontal and vertical coordinates to the location to
start printing $string.
Normally I'd use printf to force rounding or decimals where none are
displayed, but I can't see a way of using that here. The PDF::Reuse
documentation does't provide help on this problem either.
Does anyone have any suggestions on how to force, for example '34' to be
'34.00', and 7.[lots of digits] to truncate at 4 digits after the
decimal?
All pointers to documentation or suggestions gratefully received.
Justin.
--
Justin C, by the sea.
------------------------------
Date: Fri, 05 Dec 2008 15:27:13 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: PDF::Reuse and number rounding/precision
Message-Id: <C6udnSdIX4_21KTUnZ2dnUVZ8uadnZ2d@posted.plusnet>
Justin C wrote:
> I'm using PDF::Reuse to produce output in a PDF template. The problems
> I'm having are:
> * I need to print currency values with two decimal places regardless of
> whether the number has anything after the decimal point.
> * I need to print values for weight with up to four digits after the
> decimal point (if there are digits).
>
> What PDF::Reuse is doing is only printing integars where there is
> nothing after the decimal for my currency output, and printing fourteen
> digits after the decimal in places where I need rounding.
>
> I'm using the following to produce output:
>
> prText($x, $y, $string)
>
> $x and $y are horizontal and vertical coordinates to the location to
> start printing $string.
>
> Normally I'd use printf to force rounding or decimals where none are
> displayed, but I can't see a way of using that here. The PDF::Reuse
> documentation does't provide help on this problem either.
>
> Does anyone have any suggestions on how to force, for example '34' to be
> '34.00', and 7.[lots of digits] to truncate at 4 digits after the
> decimal?
wouldn't
prText($x, $y, sprintf("%.2f", $string));
be helpful?
(untested, worth what you paid)
BugBear
------------------------------
Date: Fri, 5 Dec 2008 08:01:26 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: PDF::Reuse and number rounding/precision
Message-Id: <13d1b247-672d-448f-b671-ad87ad431f05@41g2000yqf.googlegroups.com>
On Dec 5, 10:27=A0am, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> Justin C wrote:
> > I'm using PDF::Reuse to produce output in a PDF template. The problems
> > I'm having are:
> > * I need to print currency values with two decimal places regardless of
> > =A0 whether the number has anything after the decimal point.
> > * I need to print values for weight with up to four digits after the
> > =A0 decimal point (if there are digits).
>
> > What PDF::Reuse is doing is only printing integars where there is
> > nothing after the decimal for my currency output, and printing fourteen
> > digits after the decimal in places where I need rounding.
>
> > I'm using the following to produce output:
>
> > =A0 =A0 prText($x, $y, $string)
>
> > $x and $y are horizontal and vertical coordinates to the location to
> > start printing $string.
>
> > Normally I'd use printf to force rounding or decimals where none are
> > displayed, but I can't see a way of using that here. The PDF::Reuse
> > documentation does't provide help on this problem either.
>
> > Does anyone have any suggestions on how to force, for example '34' to b=
e
> > '34.00', and 7.[lots of digits] to truncate at 4 digits after the
> > decimal?
>
> wouldn't
>
> =A0 =A0 prText($x, $y, sprintf("%.2f", $string));
>
> be helpful?
>
> (untested, worth what you paid)
>
> =A0 =A0BugBear- Hide quoted text -
>
> - Show quoted text -
While we don't use PDF::Reuse, we do routinely produce PDF reports,
and your call to sprintf is precisely what we used (actually within
our own function to add currency symbols and commas). Now we prefer
the Data::Currency package, but be warned you need to pay attention to
locale issues if you need to display, say, the Euro symbol (it is
easier to just use the character code for the currency, such as USD
for US dollars). This package makes it easier to get handling of
symbols and delimiters right for different currencies.
Cheers,
Ted
------------------------------
Date: Fri, 05 Dec 2008 10:03:05 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: PDF::Reuse and number rounding/precision
Message-Id: <493950b9$0$87073$815e3792@news.qwest.net>
Justin C wrote:
> I'm using PDF::Reuse to produce output in a PDF template. The problems
> I'm having are:
> * I need to print currency values with two decimal places regardless of
> whether the number has anything after the decimal point.
> * I need to print values for weight with up to four digits after the
> decimal point (if there are digits).
>
> What PDF::Reuse is doing is only printing integars where there is
> nothing after the decimal for my currency output, and printing fourteen
> digits after the decimal in places where I need rounding.
>
> I'm using the following to produce output:
>
> prText($x, $y, $string)
>
> $x and $y are horizontal and vertical coordinates to the location to
> start printing $string.
>
> Normally I'd use printf to force rounding or decimals where none are
> displayed, but I can't see a way of using that here. The PDF::Reuse
> documentation does't provide help on this problem either.
Complete guess..
prText($x, $y, sprintf( "%.2f", $string) );
>
> Does anyone have any suggestions on how to force, for example '34' to be
> '34.00', and 7.[lots of digits] to truncate at 4 digits after the
> decimal?
sprintf( "%.4f", $val )
>
> All pointers to documentation or suggestions gratefully received.
perldoc -f sprintf
------------------------------
Date: Fri, 5 Dec 2008 08:11:57 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: PDF::Reuse and number rounding/precision
Message-Id: <d1be0d45-1b5e-45d1-84f6-b2d45c6d613b@k36g2000yqe.googlegroups.com>
On Dec 5, 11:01=A0am, Ted Byers <r.ted.by...@gmail.com> wrote:
> On Dec 5, 10:27=A0am, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
>
>
>
>
>
> > Justin C wrote:
> > > I'm using PDF::Reuse to produce output in a PDF template. The problem=
s
> > > I'm having are:
> > > * I need to print currency values with two decimal places regardless =
of
> > > =A0 whether the number has anything after the decimal point.
> > > * I need to print values for weight with up to four digits after the
> > > =A0 decimal point (if there are digits).
>
> > > What PDF::Reuse is doing is only printing integars where there is
> > > nothing after the decimal for my currency output, and printing fourte=
en
> > > digits after the decimal in places where I need rounding.
>
> > > I'm using the following to produce output:
>
> > > =A0 =A0 prText($x, $y, $string)
>
> > > $x and $y are horizontal and vertical coordinates to the location to
> > > start printing $string.
>
> > > Normally I'd use printf to force rounding or decimals where none are
> > > displayed, but I can't see a way of using that here. The PDF::Reuse
> > > documentation does't provide help on this problem either.
>
> > > Does anyone have any suggestions on how to force, for example '34' to=
be
> > > '34.00', and 7.[lots of digits] to truncate at 4 digits after the
> > > decimal?
>
> > wouldn't
>
> > =A0 =A0 prText($x, $y, sprintf("%.2f", $string));
>
> > be helpful?
>
> > (untested, worth what you paid)
>
> > =A0 =A0BugBear- Hide quoted text -
>
> > - Show quoted text -
>
> While we don't use PDF::Reuse, we do routinely produce PDF reports,
> and your call to sprintf is precisely what we used (actually within
> our own function to add currency symbols and commas). =A0Now we prefer
> the Data::Currency package, but be warned you need to pay attention to
> locale issues if you need to display, say, the Euro symbol (it is
> easier to just use the character code for the currency, such as USD
> for US dollars). =A0This package makes it easier to get handling of
> symbols and delimiters right for different currencies.
>
> Cheers,
>
> Ted- Hide quoted text -
>
> - Show quoted text -
OOPS! I forgot to mention that fine package:
Locale::Currency::Format
Worth checking out.
Ted
------------------------------
Date: 05 Dec 2008 17:05:59 GMT
From: xhoster@gmail.com
Subject: Re: sysread and syswrite analogy
Message-Id: <20081205120457.798$Sd@newsreader.com>
sln@netherlands.com wrote:
> Am I missing something here? Level I and level II with regard to i/o?
> I thought syswrite/sysread were Level I i/o.
What are "Level I" and "Level II" I/O? AFAICT, these terms are not used
in the Perl docs, or the Linux man pages. They seem to be part of your own
private language.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Fri, 5 Dec 2008 07:00:39 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: Why would it appear to my scripts that a server they're connecting to has gone away (using Net::FTP and LWP)
Message-Id: <56352cd4-fb2d-43e5-9bac-dbc386c18dd4@j32g2000yqn.googlegroups.com>
On Dec 5, 3:30=A0am, Tim Greer <t...@burlyhost.com> wrote:
> Ted Byers wrote:
> > Net::FTP=3DGLOB(0x3e18a04): Timeout at C:/Perl/site/lib/Net/FTP/
> > dataconn.pm line 7
>
> What does the error log say on the remote site? =A0Did you run any tools
> or commands to check the connectivity? =A0How's the route from your ISP
> connection to the remote host, especially when this happens? =A0How about
> the route back, if you can get that information? =A0Did you test
> FTP/uploading/downloading for the same site via a normal FTP client or
> from the ftp command on the command line to verify it works without
> issue every time, and only fails when you use the script, or are you
> only testing this with the script?
> --
> Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> and Custom Hosting. =A024/7 support, 30 day guarantee, secure servers.
> Industry's most experienced staff! -- Web Hosting With Muscle!
Thanks Tim,
So far I have tested only with my script. This is a new problem
domain for me, as I have not written code to automate ftp before a
week ago. I am therefore groping in the dark, as it were. Getting
the basic stuff to work isn't so much a problem as making it reliable.
I don't have remote access to the error log on the remote site (but I
have directed my colleague in the office to scrutinize that.
What tools would you recommend to check connectivity between sites
(both are actually remote for me, one 100 KM away and the other much
further), and both live behind a firewall so outside access is
severely restricted, so what I'll have to do is run whatever tool s
available from the remote desktop, if that matters.
Thanks
Ted
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 2036
***************************************