[31257] in Perl-Users-Digest
Perl-Users Digest, Issue: 2502 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 4 21:09:43 2009
Date: Sat, 4 Jul 2009 18:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 4 Jul 2009 Volume: 11 Number: 2502
Today's topics:
Re: Best way to do server side tasks with new ISP <rvtol+usenet@xs4all.nl>
Re: Best way to do server side tasks with new ISP <cwilbur@chromatico.net>
cancer <nadmoh680@gmail.com>
Re: Compare, two identical numbers are not the same?! sln@netherlands.com
Excel Formatting <rajpreetsidhu@gmail.com>
Re: Excel Formatting <cartercc@gmail.com>
Re: FAQ 4.57 What happens if I add or remove keys from <uri@stemsystems.com>
Re: FAQ 4.57 What happens if I add or remove keys from <uri@stemsystems.com>
Re: FAQ 4.57 What happens if I add or remove keys from <whynot@pozharski.name>
Re: FAQ 4.57 What happens if I add or remove keys from <someone@example.com>
Sarah Palin will not re-run for Governor of Alaska <asim.ssat@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 04 Jul 2009 13:24:40 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <4a4f3bf8$0$193$e4fe514c@news.xs4all.nl>
Charlton Wilbur wrote:
> Given the following line:
>
> foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true
>
> Produce the following output:
>
> * An alphabetically sorted list of the values assigned to each variable
> * The count of values assigned to each variable
> * The result of foo * 27 + 3
perl -wle '
my $line =
"foo=1;bar=yes;baz=c;baz=b;baz=c;quux=seven;quux=;submit=true";
my %par; push @{ $par{$1} }, $2 while $line =~ /([^=;]+)=([^;]+)/g;
print for sort map @$_, values %par; print "-"x20;
print for map scalar(@$_), values %par; print "-"x20;
print $par{foo}[0] * 27 + 3;
'
1
b
c
c
seven
true
yes
--------------------
1
3
1
1
1
--------------------
30
--
Ruud
------------------------------
Date: Sat, 04 Jul 2009 09:59:12 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Best way to do server side tasks with new ISP
Message-Id: <86hbxseehb.fsf@mithril.chromatico.net>
>>>>> "R" == Ruud <rvtol+usenet@xs4all.nl> writes:
R> Charlton Wilbur wrote:
>> [problem specification, with instructions to try solving it in C
>> and in Perl]
R> [code to solve the problem]
Well, yes, it isn't a particularly difficult problem, either in Perl or
in C. The point is that it's a couple dozen lines of Perl at most, and
probably closer to a couple hundred lines of C.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Sat, 4 Jul 2009 01:57:22 -0700 (PDT)
From: mohi <nadmoh680@gmail.com>
Subject: cancer
Message-Id: <d05ae7af-b55d-4965-90aa-fdd3fa310394@12g2000pri.googlegroups.com>
Cancer (medical term: malignant neoplasm) is a class of diseases in
which a group of cells display uncontrolled growth (division beyond
the normal limits), invasion (intrusion on and destruction of adjacent
tissues), and sometimes metastasis (spread to other locations in the
body via lymph or blood).
for more details visit http://abdulmohsi.blogspot.com/2009/07/cancer.html
------------------------------
Date: Sat, 04 Jul 2009 15:50:59 -0700
From: sln@netherlands.com
Subject: Re: Compare, two identical numbers are not the same?!
Message-Id: <9mmv4515mrb2ai16h8d2l9ff223d07an0m@4ax.com>
On Thu, 02 Jul 2009 22:48:58 -0000, Justin C <justin.0903@purestblue.com> wrote:
>On 2009-06-30, Jürgen Exner <jurgenex@hotmail.com> wrote:
>> Justin C <justin.0903@purestblue.com> wrote:
>>>On 2009-06-29, Jürgen Exner <jurgenex@hotmail.com> wrote:
>>>> You forgot the first commandment of computer numerics:
>>>>
>>>> Thou shalt not use equality for floating point numbers!
>>>
>>>OK. I can be certain that a user will never put in a number using more
>>>than two decimal places - if they do I can reject it. Would I be better
>>>off multiplying the input data by 100 and working in integars only?
>>
>> That would be one common approach to avoid any inaccuracies caused by
>> floating point arithmetic.
>
>I'll try and remember this for another time I might need it.
>
>
>>>On the other hand, the sprintf trick works. Maybe I should just try and
>>>remember not to compare floats -
>>
>> It is ok to compare floats for smaller/larger. But instead of checking
>> for equal you must check if the difference between the two numbers is
>> smaller than some tiny number. How large that tiny number is depends on
>> your application area, but it will never be 100% accurate.
>
>Thank you, Jurgen and CC. I'm doing a straight compare of two sprintf
>'numbers', but I quite like the idea of testing the difference - a
>tollerance as CC put it. I might re-write the code for proof of concept,
>and "doing it" actually gets it into my head better than reading it.
>
> Justin.
The ballpark for comparisons are C functions ceil/floor (posix in perl).
Never can you compare doubles for equality, and never can you even see a
print of thier actual float value.
There is only one need for true comparisons, the is the case of
Numerical Methods absolute "difference" being less/greater than some
value. Or in the case of rounding is needed (ala the Pentium 60 bug
where zero is less than some absolute value of some really small fraction
of 1).
-sln
------------------------------
Date: Fri, 3 Jul 2009 06:39:46 -0700 (PDT)
From: Rajpreet <rajpreetsidhu@gmail.com>
Subject: Excel Formatting
Message-Id: <8cb4e8ac-22eb-4264-81ee-325279fc8986@k13g2000prh.googlegroups.com>
Greetings,
I am trying to generate an excel report based using perl
spreadsheet::writeexcel.pm module.
I have a column header as say "Example Name: <<Variable_input>>".
This whole context is in one single cell. However, I need to have
"Example Name" as bold, and Variable_Input as a normal font character.
I tried splitting the two strings into two cells , but this is causing
allignment issues in my report , for the lower cells of the report.
Can someone please help? Any way of having two formats in one single
cell using spreadsheet::writetext?
Appreciate your reply.
Regards,
Rajpreet
------------------------------
Date: Fri, 3 Jul 2009 07:45:23 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Excel Formatting
Message-Id: <5824c62f-c582-4d73-8daf-100f4bfabe8b@h11g2000yqb.googlegroups.com>
On Jul 3, 9:39=A0am, Rajpreet <rajpreetsi...@gmail.com> wrote:
> Greetings,
>
> I am trying to generate an excel report based using perl
> spreadsheet::writeexcel.pm module.
> I have a column header as say "Example Name: =A0<<Variable_input>>".
> This whole context is in one single cell. However, I need to have
> "Example Name" as bold, and Variable_Input as a normal font character.
>
> I tried splitting the two strings into two cells , but this is causing
> allignment issues in my report , for the lower cells of the report.
>
> Can someone please help? Any way of having two formats in one single
> cell using spreadsheet::writetext?
>
> Appreciate your reply.
>
> Regards,
> Rajpreet
The default format for Excel 2007 is OOXML. You can generate an Excel
file, with an XSLX extension, by producing an ASCII text file.
Doing it manually is extremely tedious. However, if you are generating
a report template to use on a regular basis, it's no worse than
writing a script that you run at regular intervals.
I haven't tried this, but according to the Microsoft documentation, if
you change the .xlsx extension to a .zip extension and open it with a
zip utility, you can read the files that create the workbook.
I produce a lot of Excel readable files in csv format, which is good
for my needs, so I haven't experimented with xlsx. However, I also
produce Word files and generate .doc documents using WordProcessingML,
the predecessor to OOXML 2007, and it works very well.
CC
------------------------------
Date: Sat, 04 Jul 2009 19:09:46 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FAQ 4.57 What happens if I add or remove keys from a hash while iterating over it?
Message-Id: <871vowcaf9.fsf@quad.sysarch.com>
>>>>> "EP" == Eric Pozharski <whynot@pozharski.name> writes:
EP> $h{$_} = $_ foreach 0 .. 1E4;
since i like slices:
%h{ 0 .. 1e4 } = 0 .. 1E4 ;
EP> while( $x = each %h ) {
EP>
EP> delete $h{$x + 1};
EP> push @z, $x + 1;
and very few seem to know that delete returns its value and since your
keys and values are the same:
push @z, delete $h{$x + 1} ;
:)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Sat, 04 Jul 2009 21:00:40 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: FAQ 4.57 What happens if I add or remove keys from a hash while iterating over it?
Message-Id: <87tz1saqpz.fsf@quad.sysarch.com>
>>>>> "JWK" == John W Krahn <someone@example.com> writes:
JWK> Uri Guttman wrote:
>>>>>>> "EP" == Eric Pozharski <whynot@pozharski.name> writes:
>>
EP> $h{$_} = $_ foreach 0 .. 1E4;
>>
>> since i like slices:
>>
>> %h{ 0 .. 1e4 } = 0 .. 1E4 ;
JWK> ITYM:
JWK> @h{ 0 .. 1e4 } = 0 .. 1E4 ;
yep. i cut/pasted your code and forgot to change it.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Sat, 04 Jul 2009 15:59:37 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: FAQ 4.57 What happens if I add or remove keys from a hash while iterating over it?
Message-Id: <slrnh4uki7.8ar.whynot@orphan.zombinet>
On 2009-07-03, brian d foy <brian.d.foy@gmail.com> wrote:
> In article <ji3sh6-d661.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
><ben@morrow.me.uk> wrote:
>
>> Quoth PerlFAQ Server <brian@stonehenge.com>:
>> >
>> > 4.57: What happens if I add or remove keys from a hash while iterating over
>> > it?
>
>
>> Deleting *any* key is safe, and has the obvious result. If you've seen
>> it already, you won't see it again; if you haven't, you won't see it at
>> all. Deleting an entry never causes Perl hashes to rehash, so it won't
>> affect any other keys.
>
> This is contrary to the documentation for each() in perlfunc. I'm
> taking perlfunc as the more authoratative source. If there's a problem,
> someone needs to fix it there first.
I think there *is* problem with F<perlfunc>
perl -wle '
$h{$_} = $_ foreach 0 .. 1E4;
print scalar %h;
while( $x = each %h ) {
delete $h{$x + 1};
push @z, $x + 1;
print "already deleted: $x"
if grep $_ == $x, @z;
};
print scalar %h;
'
7391/16384
3526/16384
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Sat, 04 Jul 2009 16:30:09 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: FAQ 4.57 What happens if I add or remove keys from a hash while iterating over it?
Message-Id: <6CR3m.13907$wE4.1462@newsfe02.iad>
Uri Guttman wrote:
>>>>>> "EP" == Eric Pozharski <whynot@pozharski.name> writes:
>
> EP> $h{$_} = $_ foreach 0 .. 1E4;
>
> since i like slices:
>
> %h{ 0 .. 1e4 } = 0 .. 1E4 ;
ITYM:
@h{ 0 .. 1e4 } = 0 .. 1E4 ;
> EP> while( $x = each %h ) {
> EP>
> EP> delete $h{$x + 1};
> EP> push @z, $x + 1;
>
> and very few seem to know that delete returns its value and since your
> keys and values are the same:
>
> push @z, delete $h{$x + 1} ;
>
> :)
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
------------------------------
Date: Sat, 4 Jul 2009 09:19:30 -0700 (PDT)
From: asim malik <asim.ssat@gmail.com>
Subject: Sarah Palin will not re-run for Governor of Alaska
Message-Id: <0f61abd6-93a0-4b08-9f88-748cd39e65e5@l5g2000pra.googlegroups.com>
ALASKA: Several media sources are now reporting that former Republican
vice-presidential candidate Sarah Palin will not run for re-election
as the Governor of Alaska.
for more details visit : www.nfa786.blogspot.com
------------------------------
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 2502
***************************************