Re: freeze-thaw - socket/file handle to ref then string

2005-07-25 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:

 hello all,
 
 here is a ref/deref problem
 
 I need to take a socket handle, convert it to a socket ref, then a scaler 
 string 
 
 A bit later in the same script, I need to take that scaler string and turn it 
 back to a socket ref, and deref it back to the socket handle. 

Maybe instead of asking for the way to implement your solution, you should
describe the complete problem and see if we can come up with an alternate
solution that is a little less convoluted.  :)

 An example would be great,

Sure - you got one ?

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: comparing floating point numbers

2005-07-25 Thread Chris Wagner
At 10:40 PM 7/24/05 -0400, Ted Schuerzinger wrote:
Ken Barker graced perl with these words of wisdom:
 What kind of post is this?
It was an informative help post, made especially informative and helpful 
by the fact that the relevant material was included at the relevant point 
in the code, as opposed to being top-posted.

Well, I'll have to agree that there should have been some more snippage to
clarify where the reply was.





--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede males

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


re: comparing floating point numbers

2005-07-25 Thread Chris Wagner
At 04:07 PM 7/24/05 -0400, John Deighan wrote:
Sorry about the lack of sample code, but I know that people who work 
with floating point numbers know about this problem, and I was 
wondering what the best solution was. Here is sample code with 

Well ur right, the easy answer is to do the $diff  .0001 route.  If you
really want the hard core way, be prepared to engage in some heavy wizardy
and/or pain.  What u have to do is basically take over numeric processing
from perl and do everything in scientific notation.  Then provide all ur own
arithmetic functions.  Of course I'm sure somebody has already implemented a
module to do this.  Numbers will then be represented as two element arrays
of an integer and an integer power of ten.  2.35 = 235*10^-2 = (235, -2).
Bye bye floats.  U can override the builtin math operators or provide
functions.  Another outside thing u can do is do everything in base 210
numbers.  Why 210?  It's the product of all the prime numbers less than 10
so it can eliminate run-on fractions.  But I digress.







--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede males

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: comparing floating point numbers

2005-07-25 Thread robert


On Sunday, July 24, 2005 at 6:11 PM, Ken Barker wrote:
 
 What kind of post is this?
 
 I do not see that anything was added at all.  Give us all a 
 break - don't 
 bother - whatever your intentions.
 


well, don't you feel stupid now?



 
 At 06:35 PM 7/24/2005, $Bill Luebkert wrote:
 John Deighan wrote:
   At 02:20 PM 7/24/2005, Ed Chester wrote:
  
  
  John Deighan::
  
  Is there a safe way to compare 2 floating point numbers in Perl? 
  [snip] My debugger says that they're both '630.24' 
 [snip] However, 
  the == test fails and the != test succeeds
  
  can you post code with the comparison == that fails ?
  if the debugger says they're the same, they're very very probably 
  the same. are you sure the variable (or whatever) you're 
 giving to 
  == are really  what you want them to be?
  there are lots of ways to compare numbers, right down to 
 looping over 
  the bits
  and logically
  XNORing them.
  
  
   Sorry about the lack of sample code, but I know that 
 people who work 
   with floating point numbers know about this problem, and I was 
   wondering what the best solution was. Here is sample code with 
   output. Note that I'm not formatting the output or rounding or 
   anything - just printing out the contents of the 2 variables.
  
   my $sum1 = -237.15;
   my $sum2;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
   $sum2 += -26.35;
  
   print(sum1 = $sum1\n);
   print(sum2 = $sum2\n);
   if ($sum1 == $sum2) {
 
 You could try something like:
 
if (abs ($sum1 - $sum2)  .0001) {
 
print(EQUAL\n);
}
   else {
print(NOT EQUAL\n);
}
  
   OUTPUT:
  
   sum1 = -237.15
   sum2 = -237.15
   NOT EQUAL
  
  
   ___
   Perl-Win32-Users mailing list 
   Perl-Win32-Users@listserv.ActiveState.com
   To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 
 
 --
,-/-  __  _  _ $Bill Luebkert
 Mailto:[EMAIL PROTECTED]
   (_/   /  )// //   DBE 
 CollectiblesMailto:[EMAIL PROTECTED]
/ ) /--  o // //  Castle of Medieval Myth  Magic 
  http://www.todbe.com/
 -/-' /___/__/_/_http://dbecoll.tripod.com/ (My 
 Perl/Lakers stuff)
 ___
 Perl-Win32-Users mailing list 
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 ___
 Perl-Win32-Users mailing list 
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: comparing floating point numbers

2005-07-25 Thread robert
use sprintf to set the floating point field to 2 decimal places. (or
more, if you want them...)  

$float1=-135.176# final values before rounding
$float2=-135.184

$float1=sprintf(%.2f,$float1);# force $float1 to be rounded at 2
decimal places
$float2=sprintf(%.2f,$float2);# ditto $float2

print $float1\n$float2\n;

if ($float1 == $float2) {
printvalues are EQUAL\n;
}
else { printvalues are NOT EQUAL\n; }


the example above will return

-135.18
-135.18
   values are EQUAL

change 
$float1 = 255.733
$float2 = 255.735

and this will return

255.73
255.74 
   values are NOT EQUAL




 -Original Message-
 From: John Deighan
 
 my $sum1 = -237.15;
 my $sum2;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 
 print(sum1 = $sum1\n);
 print(sum2 = $sum2\n);
 if ($sum1 == $sum2) {
  print(EQUAL\n);
  }
 else {
  print(NOT EQUAL\n);
  }
 
 OUTPUT:
 
 sum1 = -237.15
 sum2 = -237.15
 NOT EQUAL
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


activeperl + mysql + threads = crash

2005-07-25 Thread Foo Ji-Haw

Hi all,

I thought I can hit a nice milestone today, but it seems that I have hit 
a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI-connect('dbi:mysql:database','username','password');
  my $stmt = $dbh-prepare ('select id from tablename');
  $stmt-execute();
  while (my $record=$stmt-fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, table 
name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection and 
it's fine.
2. The problem lies with using threads alongside DBI. If I take out 'use 
threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take that 
out, all is fine.


Can someone confirm this? Is there anybody who can suggest a workaround? 
Thanks.


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: comparing floating point numbers

2005-07-25 Thread robert

use sprintf to set the floating point field to 2 decimal places. (or
more, if you want them...)  

$float1=-135.176# final values before rounding
$float2=-135.184

$float1=sprintf(%.2f,$float1);# force $float1 to be rounded at 2
decimal places
$float2=sprintf(%.2f,$float2);# ditto $float2

print $float1\n$float2\n;

if ($float1 == $float2) {
printvalues are EQUAL\n;
}
else { printvalues are NOT EQUAL\n; }


the example above will return

-135.18
-135.18
   values are EQUAL

change 
$float1 = 255.733
$float2 = 255.735

and this will return

255.73
255.74 
   values are NOT EQUAL




 -Original Message-
 From: John Deighan
 
 my $sum1 = -237.15;
 my $sum2;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 $sum2 += -26.35;
 
 print(sum1 = $sum1\n);
 print(sum2 = $sum2\n);
 if ($sum1 == $sum2) {
  print(EQUAL\n);
  }
 else {
  print(NOT EQUAL\n);
  }
 
 OUTPUT:
 
 sum1 = -237.15
 sum2 = -237.15
 NOT EQUAL
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: activeperl + mysql + threads = crash

2005-07-25 Thread Reinhard Pagitsch

Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub disconnect_all.
Removing use threads;  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I have 
hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI-connect('dbi:mysql:database','username','password');
  my $stmt = $dbh-prepare ('select id from tablename');
  $stmt-execute();
  while (my $record=$stmt-fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take out 
'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard






--
QA
ISIS Information Systems
Austria tel: (+43) 2236 27551 150  Fax: 2236 21081
Visit our web site http://www.isis-papyrus.com
---
This e-mail is only intended for the recipient and not legally
binding. Unauthorised use, publication, reproduction or
disclosure of the content of this e-mail is not permitted.
---

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: activeperl + mysql + threads = crash

2005-07-25 Thread Foo Ji-Haw

Hello Reinhard,

Thanks for confirming my concerns. So you say that on 5.6.x it is ok, 
but not on 5.8.x. But threading + mysql is quite a powerful combination 
to give up!


I wonder if anybody in this mailing list has a workaround/ solution.

Reinhard Pagitsch wrote:


Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub disconnect_all.
Removing use threads;  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I 
have hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates an 
error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI-connect('dbi:mysql:database','username','password');
  my $stmt = $dbh-prepare ('select id from tablename');
  $stmt-execute();
  while (my $record=$stmt-fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take out 
'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard







___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: activeperl + mysql + threads = crash

2005-07-25 Thread Reinhard Pagitsch


---BeginMessage---

Hello,

I made an additional test:
Using the code below Perl v5.8.7 does not crash. In the Task Manager I 
can see that Perl uses 3 threads.

With the original code he uses only one thread.
--- new code --
use strict;
use warnings;
use DBI;
use threads;

print first\n;
my $thread = threads-new(doIt,argument);
print scound\n;
my $thread1 = threads-new(doIt,argument);
$thread-join();
$thread1-join();
$thread-detach();
$thread1-detach();


sub doIt
{
   my $Thishost = $ENV{COMPUTERNAME};
   my $addr = (gethostbyname($Thishost))[4];
   $addr = join(., unpack(C4, $addr));   
   my $dsn = DBI:mysql:database=resources;host=$addr;
   my $dbh = DBI-connect($dsn,user, password) or die can not 
connect to database \n;

#  my $dbh = DBI-connect('dbi:mysql:database','user','password');
 my $stmt = $dbh-prepare ('select resolution from resources');
 $stmt-execute();
 while (my $record=$stmt-fetchrow_hashref('NAME_lc')) {

 }

 $dbh-disconnect;
}

--- end new code --


Foo Ji-Haw wrote:


Hello Reinhard,

Thanks for confirming my concerns. So you say that on 5.6.x it is ok, 
but not on 5.8.x. But threading + mysql is quite a powerful 
combination to give up!


I wonder if anybody in this mailing list has a workaround/ solution.

Reinhard Pagitsch wrote:


Hello,

I tryed it also with Perl v5.8.7 and had the same prroblem as you, on 
the 2nd doIt Perl crashes.

I also found out that Perl crashes in the DBI.pm sub disconnect_all.
Removing use threads;  it works.

regards,
Reinhard

Foo Ji-Haw wrote:


Hello Reinhard,

I am using 5.8.6 of ActivePerl. Thanks for checking out the codes.

Reinhard Pagitsch wrote:


Hello,


Foo Ji-Haw wrote:


Hi all,

I thought I can hit a nice milestone today, but it seems that I 
have hit a strange obstacle instead.
In my tests, the following code will run, but when it terminates 
an error message will be shown.

use strict;
use warnings;
use DBI;
use threads;

doIt();
doIt();

sub doIt
{
  my $dbh = DBI-connect('dbi:mysql:database','username','password');
  my $stmt = $dbh-prepare ('select id from tablename');
  $stmt-execute();
  while (my $record=$stmt-fetchrow_hashref('NAME_lc')) {}
}

Change the database connection parameters (eg. username, password, 
table name) to your database.


My analysis of the problem is as follows:
1. Using the ODBC driver is ok. I've tested with MSSQL connection 
and it's fine.
2. The problem lies with using threads alongside DBI. If I take 
out 'use threads' all is well.
3. There are 2x doIt() calls because it only fails on the second 
database connection.
4. It seems to be related to fetchrow_hashref(), because if I take 
that out, all is fine.


Can someone confirm this? Is there anybody who can suggest a 
workaround? Thanks.



There is no problem here, Perl v5.6.1. Which Perl version do you use?

regards,
Reinhard











--
QA
ISIS Information Systems
Austria tel: (+43) 2236 27551 150  Fax: 2236 21081
Visit our web site http://www.isis-papyrus.com
---
This e-mail is only intended for the recipient and not legally
binding. Unauthorised use, publication, reproduction or
disclosure of the content of this e-mail is not permitted.
---


---End Message---
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: activeperl + mysql + threads = crash

2005-07-25 Thread Paul Sobey
 I thought I can hit a nice milestone today, but it seems that 
 I have hit 
 a strange obstacle instead.
 In my tests, the following code will run, but when it terminates an 
 error message will be shown.
 use strict;
 use warnings;
 use DBI;
 use threads;
 
 doIt();
 doIt();

[snip]

 Can someone confirm this? Is there anybody who can suggest a 
 workaround? 

The following links imply that DBD::mysql is not threadsafe by default
due to the underlying C library, but can be made so by recompiling. Not
sure whether anyone has any updates on this.

http://aspn.activestate.com/ASPN/Mail/Message/perl-DBI-Dev/2241467
http://search.cpan.org/~jwied/Msql-Mysql-modules-1.2219/mysql/lib/DBD/my
sql.pm#MULTITHREADING

Paul

*
Gloucester Research Limited believes the information 
provided herein is reliable. While every care has been 
taken to ensure accuracy, the information is furnished 
to the recipients with no warranty as to the completeness 
and accuracy of its contents and on condition that any 
errors or omissions shall not be made the basis for any 
claim, demand or cause for action.
*


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


voice

2005-07-25 Thread Octavian Rasnita
Hi,

I have tried the following script under Windows 2000 (probably SAPI 4), but
it doesn't speak anything.

Can you give me the right code?

Thank you much.

Teddy


use strict;

use Win32::OLE;
my $voice = Win32::OLE-new(Speech.VoiceText);
$voice-Register('', 'Perl');
$voice-speak(hello world);
STDIN;# wait til it finishes speaking

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: voice

2005-07-25 Thread Reinhard Pagitsch

Hi,

Octavian Rasnita wrote:


Hi,

I have tried the following script under Windows 2000 (probably SAPI 4), but
it doesn't speak anything.

Can you give me the right code?

Thank you much.

Teddy


use strict;

use Win32::OLE;
my $voice = Win32::OLE-new(Speech.VoiceText);
$voice-Register('', 'Perl');
$voice-speak(hello world);
STDIN;# wait til it finishes speaking

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

 

Take a look at 
http://opensource.activestate.com/authors/jandubois/Perl/TPC3/fun.html#Can_I_access_COM_OLE_objects_f

and
http://www.archivum.info/perl-win32-users@listserv.activestate.com/2005-06/msg00126.html

regards,
Reinhard

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: comparing floating point numbers

2005-07-25 Thread James Sluka




<>Robert's solution (rounding with sprintf) is pretty good, except
it requires that you 
know something about the numbers. For example, they must differ by more
than 0.01 to 
be considered different. What happens when the two numbers are;
 0.101
 0.100
Now you need to check for differences beyond 0.1, actually
0.001

Perhaps a better way, one that doesn't require any knowledge of the
range of the numbers, 
is to check the ratio of the two numbers. This should eliminate (or
reduce) the dependence 
on their magnitudes. So, instead of comparing the original numbers (or
the rounded 
numbers) compare their ratio; 
 abs(1-$sum1/$sum2) = 1e-12
If the numbers are "equal", the ratio will be something like
0.99 or 1.01, 
depending on which of the two numbers is bigger. The abs and "1-"
removes the dependence 
on which of the two numbers is bigger, and shifts the value to near
zero, giving a single 
result such as 0.01.

On my Winblows 98 machine the difference between the two numbers is
-2.8421709430404e-014
So a cutoff value of 1e-12 is probably suitable. Other platforms may
need a different cutoff value
depending on their native precision. I suspect 1e-10 might be a good,
platform independent, value.

use strict; ## added

my $sum1 = -237.15;
my $sum2;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;

print("sum1 = $sum1\n");
print("sum2 = $sum2\n");
print "Difference =".($sum1-$sum2)."\n";   ## what is the actual
diff between the numbers?
print "Ratio = ".($sum1/$sum2)."\n"; 
print "(1-Ratio) = ".(1-$sum1/$sum2)."\n\n";

if ( abs(1-$sum1/$sum2) = 1e-12 ) { ## new test
 print("EQUAL\n");
} else {
 print("NOT EQUAL\n");
}

-
OUTPUT:
sum1 = -237.15
sum2 = -237.15
Difference =-2.8421709430404e-014
Ratio = 1
(1-Ratio) = -2.22044604925031e-016

EQUAL


J. Sluka
InPharmix Inc.


robert wrote:

  use "sprintf" to set the floating point field to 2 decimal places. (or
more, if you want them...)  

$float1=-135.176		# final values before rounding
$float2=-135.184		

$float1=sprintf("%.2f",$float1);# force $float1 to be rounded at 2
decimal places
$float2=sprintf("%.2f",$float2);# ditto $float2

print "$float1\n$float2\n";

if ($float1 == $float2) {
	print "   values are EQUAL\n";
}
else { print "   values are NOT EQUAL\n"; }


the example above will return

-135.18
-135.18
   values are EQUAL

change 
$float1 = 255.733
$float2 = 255.735

and this will return

255.73
255.74 
   values are NOT EQUAL


	

  
  
-Original Message-
From: John Deighan

my $sum1 = -237.15;
my $sum2;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;
$sum2 += -26.35;

print("sum1 = $sum1\n");
print("sum2 = $sum2\n");
if ($sum1 == $sum2) {
 print("EQUAL\n");
 }
else {
 print("NOT EQUAL\n");
 }

OUTPUT:

sum1 = -237.15
sum2 = -237.15
NOT EQUAL

  
   

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

  



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


re: comparing floating point numbers

2005-07-25 Thread Ed Chester

this is top-posted because it doesn't follow from any one of the previous posts.

just a warning to be careful of subtracting or dividing similar numbers in
floating point
and what your expectations are for the results. google for 'catastrophic loss of
precision' 
or similar, or check out the floating point standard (IEEE #754) for why these
fall apart.
*most* tests of equality, or relative size, in *most* architectures, map to
subtractions 
by the time they get the processor. watch out. 

just a tuppence / 2 eurocents worth. 

ed c


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: references

2005-07-25 Thread mailware
hello again,

  hello all,
  
  here is a ref/deref problem
  
  I need to take a socket handle, convert it to a socket ref, then a scaler 
  string 
  
  A bit later in the same script, I need to take that scaler string and turn
 it 
  back to a socket ref, and deref it back to the socket handle. 
 
 Maybe instead of asking for the way to implement your solution, you should
 describe the complete problem and see if we can come up with an alternate
 solution that is a little less convoluted.  :)

let me clarify my problem.

I have a reference of a subroutine.

eg.

$sub = test;

..deref and execute

$sub;

...

sub test {
my ($sockethandle,$blah...) = @_;
..do something
}


in order to pass the paramenters, i decided to do this : 

sub main {

my $sub = test|$sockethandle;
($sub,@_) = split(/\|/,$sub);

$sub;
}


if this is to work correctly, I need to take a socket handle, convert it to a 
socket ref, then a scaler, so i can pass it as a parameter. in order to use the 
socket later, i have to take the scaler, convert it to the socket ref, then 
dereference it.

Is there an easier way to pass parameters with a subroutine reference? 






___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


references situation

2005-07-25 Thread mailware
hello again,

  hello all,
  
  here is a ref/deref problem
  
  I need to take a socket handle, convert it to a socket ref, then a scaler 
  string 
  
  A bit later in the same script, I need to take that scaler string and turn
 it 
  back to a socket ref, and deref it back to the socket handle. 
 
 Maybe instead of asking for the way to implement your solution, you should
 describe the complete problem and see if we can come up with an alternate
 solution that is a little less convoluted.  :)

let me clarify my problem.

I have a reference of a subroutine.

eg.

$sub = test;

..deref and execute

$sub;

...

sub test {
my ($sockethandle,$blah...) = @_;
..do something
}


in order to pass the paramenters, i decided to do this : 

sub main {

my $sub = test|$sockethandle;
($sub,@_) = split(/\|/,$sub);

$sub;
}


if this is to work correctly, I need to take a socket handle, convert it to a 
socket ref, then a scaler, so i can pass it as a parameter. in order to use the 
socket later, i have to take the scaler, convert it to the socket ref, then 
dereference it.

Is there an easier way to pass parameters with a subroutine reference? 
 
 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: comparing floating point numbers

2005-07-25 Thread Arms, Mike
 
Ed Chester [EMAIL PROTECTED] wrote:
 just a warning to be careful of subtracting or dividing similar
numbers in
 floating point and what your expectations are for the results. google
for
 'catastrophic loss of precision' or similar, or check out the floating
point
 standard (IEEE #754) for why these fall apart. *most* tests of
equality, or
 relative size, in *most* architectures, map to subtractions by the
time they
 get the processor. watch out. 

Ed, a cursory look at the search results from Google produced a bunch
of items that specifically referred to the floating point Error in
the first batch of Pentium chips. As this has been corrected, are there
other occurrences of 'catastrophic loss of precision' that can be
tested using modern Pentiums (e.g. II - IV) or AMD chips? Some URLs
would
be helpful here. Thanks.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: references

2005-07-25 Thread Siebe Tolsma
Why not make it a hash?

my $sub = { ref = \test, params = [$sockethandle] };
$sub-{ref}-(@{$sub-{params}});

sub test {
my $socket = shift;
# ...
}

- Original Message - 
From: [EMAIL PROTECTED]
To: $Bill Luebkert [EMAIL PROTECTED]
Cc: perl-win32-users@listserv.ActiveState.com
Sent: Monday, July 25, 2005 8:19 PM
Subject: Re: references


 hello again,

   hello all,
  
   here is a ref/deref problem
  
   I need to take a socket handle, convert it to a socket ref, then a
scaler
   string
  
   A bit later in the same script, I need to take that scaler string and
turn
  it
   back to a socket ref, and deref it back to the socket handle.
 
  Maybe instead of asking for the way to implement your solution, you
should
  describe the complete problem and see if we can come up with an
alternate
  solution that is a little less convoluted.  :)

 let me clarify my problem.

 I have a reference of a subroutine.

 eg.

 $sub = test;

 ..deref and execute

 $sub;

 ...

 sub test {
 my ($sockethandle,$blah...) = @_;
 ..do something
 }
 

 in order to pass the paramenters, i decided to do this :

 sub main {

 my $sub = test|$sockethandle;
 ($sub,@_) = split(/\|/,$sub);

 $sub;
 }


 if this is to work correctly, I need to take a socket handle, convert it
to a
 socket ref, then a scaler, so i can pass it as a parameter. in order to
use the
 socket later, i have to take the scaler, convert it to the socket ref,
then
 dereference it.

 Is there an easier way to pass parameters with a subroutine reference?






 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


text-to-speech

2005-07-25 Thread Octavian Rasnita
Hi,

I have found the following script example that can speak a text using the
standard MS text-to-speech sinthesizer.
It works fine.

I am using Windows 2000, and I have the Narrator screen reader installed and
it uses MS text-to-speech, but I have also installed IBM ViaVoice
sinthesizer for Windows, and I can use it with Narrator.

I am wondering if it is also possible to create a perl program that uses
ViaVoice sinthesizer under Windows, because ViaVoice is also SAPI compliant,
just like MS text-to-speech sinth.

I have tried (like in the example below) to replace the class ID of MS
text-to-speech with the Registry class ID of Viavoice, but it doesn't work,
giving an error that tells that the Speak method cannot be applied to an
undef variable.

I would like to use Viavoice, because it is more clear than MS
text-to-speech, and I am blind, so I would like to use it in some
applications.

Thank you very much.
Teddy


use Win32::OLE qw( EVENTS );

my $DirectSS =
new Win32::OLE( {EEE78591-FE22-11D0-8BEF-0060081841DE} );
#I have also tried this class ID from Registry for Viavoice:
##new Win32::OLE( {9657E2E0-F99F-11d2-A420-00203521503F} );

$DirectSS-Speak(Good evening, Mr. Anderson.  How's your day been?  G
+od.  Well, listen, I'm going to have to ask you to be assimilated
+ into the Borg because, yeah, resistance is futile.  Oh, and about th
+ose TPS reports.  Yeah, didja get that memo?  You see, we're putting
+new cover sheets on all our TPS reports.  By the way, I've taken the
+liberty of searching, searching, searching out. your domain controlle
+rs.  It seems they're named charles and michael.  or should i say, we
+re?  cuz now they're pete and repeat.  yeah.  how do you like that?
+by the way, if pete and repeat are in a boat and pete jumps out,
who's left?  Ok, i'll say it again.  if pete and repeat are in a boat
+and pete jumps out, who's left?  that was a little borg humor for you
+.  most people don't know about it, but we can be a regular barrel of
+ laughs when we want to.  and remember: anything is possible, except
+skiing through a revolving door.  Because then where would we be?  no
+where, that's where.  by the way, you're logged in as  . getlogin .
+.  We Borg know that kind of stuff.  It's what we do, so we have to
+be good at it.  and we are.  we're really good.  really good.  really
+, really good. in fact, so good that we know that everything about yo
+ur computer.  everything.  have a pleasant remainder of your day.  ch
+eers from the borg.
);

while( $DirectSS-{Speaking} )
{
Win32::OLE-SpinMessageLoop();
Win32::Sleep( 100 );
}


Teddy


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


(Was Re: comparing floating point numbers) now [OT]: catastrophic cancellation

2005-07-25 Thread Ed Chester

Mike wrote: [snipped]
 items that specifically referred to the floating point Error in the first
batch of Pentium chips

Sorry, I should have narrowed the search then. This is not specific to that
error, it is a consequence of
the FP number system representation. It arises in certain circumstances, but
ones that are not uncommon. I
just wanted to flag that people could be more aware of what really happens at a
hardware/number representation
level when they want to divide / compare / subtract similar numbers, so they can
watch for pitfalls. As far
as possible, avoid floating point divides. They're ugly, and they're slow. 

I spent too long designing alternative representations that avoid this, so its
one of my soap boxes when 
people complain that compares don't work as they expect.

 other occurrences of 'catastrophic loss of precision' that can be tested using
modern Pentiums

Absolutely. I don't have any code to demo this, but will try to find some
slacktime to rustle something
up. Any of the URIs below will probably give you the idea. 

 Some URLs would be helpful here. Thanks.

Sure OK, here goes: (shout if you need more)

http://www.cse.msu.edu/~cse320/Documents/FloatingPoint.pdf

http://www.cs.princeton.edu/introcs/91float/  (and scroll down to catastrophic
cancellation)

http://cs-www.bu.edu/faculty/djy/cs210/unit06.html  (see section 'Cancellation
Error')

http://www.math.uu.se/~warwick/summer04/material/reading/rump2.pdf  (if you
really want the theory)

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/393090 (from
activestate, a Python example)


ed c


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: text-to-speech

2005-07-25 Thread Chris
 I would like to use Viavoice, because it is more clear than MS
text-to-speech, and I am blind, so I would like to use it in some
applications.

 Teddy


Um  Not to be insensitive.  But this makes no sense at all. If you
are blind to the point that you need to have text narrated, how do you
manage to program?


- Chris

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


references of sub and params in a threads::shared variable

2005-07-25 Thread mailware
how do i use this hash as a shared variable to be used in threads?
eg. with threads::shared

-Jeremy A

 Why not make it a hash?
 
 my $sub = { ref = \test, params = [$sockethandle] };
 $sub-{ref}-(@{$sub-{params}});
 
 sub test {
 my $socket = shift;
 # ...
 }
 
 
  hello again,
 
hello all,
   
here is a ref/deref problem
   
I need to take a socket handle, convert it to a socket ref, then a
 scaler
string
   
A bit later in the same script, I need to take that scaler string and
 turn
   it
back to a socket ref, and deref it back to the socket handle.
  
   Maybe instead of asking for the way to implement your solution, you
 should
   describe the complete problem and see if we can come up with an
 alternate
   solution that is a little less convoluted.  :)
 
  let me clarify my problem.
 
  I have a reference of a subroutine.
 
  eg.
 
  $sub = test;
 
  ..deref and execute
 
  $sub;
 
  ...
 
  sub test {
  my ($sockethandle,$blah...) = @_;
  ..do something
  }
  
 
  in order to pass the paramenters, i decided to do this :
 
  sub main {
 
  my $sub = test|$sockethandle;
  ($sub,@_) = split(/\|/,$sub);
 
  $sub;
  }
 
 
  if this is to work correctly, I need to take a socket handle, convert it
 to a
  socket ref, then a scaler, so i can pass it as a parameter. in order to
 use the
  socket later, i have to take the scaler, convert it to the socket ref,
 then
  dereference it.
 
  Is there an easier way to pass parameters with a subroutine reference?
 
 
 
 
 
 
  ___
  Perl-Win32-Users mailing list
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: voice

2005-07-25 Thread $Bill Luebkert
Octavian Rasnita wrote:

 Hi,
 
 I have tried the following script under Windows 2000 (probably SAPI 4), but
 it doesn't speak anything.
 
 Can you give me the right code?

This works for me and you may need to D/L the speech SDK (see notes at end):

#!perl -w --

use strict;
use Win32;
use Win32::OLE;

our %A; # get commandline switches into %A
for (my $ii = 0; $ii  @ARGV; ) {
last if $ARGV[$ii] =~ /^--$/;
if ($ARGV[$ii] !~ /^-{1,2}(.*)$/) { $ii++; next; }
my $arg = $1; splice @ARGV, $ii, 1;
if ($arg =~ /^([\w]+)=(.*)$/) { $A{$1} = $2; } else { $A{$1}++; }
}

my $XP = 0;
$XP = 1 if $^O =~ /Win32/i and Win32::GetOSName() =~ /XP/;

my $class = $XP ?  SAPI.SpVoice : Speech.VoiceText;
my $debug = $A{d} || 0;
my $use_tie = $A{t} || 0;

my $text = It is now  . scalar (localtime) . \n;
$text = join ' ', @ARGV if @ARGV;
print XP=$XP; text=$text\n if $debug;

if ($use_tie) {
tie *SPEECH, 'Speech'; END { untie *SPEECH; }
print SPEECH $text;
} else {
my $voice = Win32::OLE-new($class) or die new $class: $! ($^E);
#   $voice-Register('', 'Perl');
$voice-speak($text);
}
exit;

#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

package Speech;

sub TIEHANDLE {

my $voice = Win32::OLE-new($class) or die new $class: $! ($^E);
# $voice-Register('', 'Perl');
print Tieing class $class to $_[0]\n if $debug;
bless \$voice = shift;

}

sub PRINT {
my $voice = shift;

print Speaking $text\n if $debug;
$$voice-Speak($text, 0);

}

sub DESTROY {
my $voice = shift;

print In destroy\n if $debug;
if ($XP) {
my $ret = $$voice-WaitUntilDone(1);
#   print ret=, $ret ? 'finished' : 'killed', \n;
} else {
sleep (1) while $$voice-IsSpeaking;
}

}

__END__

Notes:

Speech SDK:
http://www.microsoft.com/speech/download/sdk51/
http://download.microsoft.com/download/speechSDK/SDK/5.1/WXP/EN-US/speechsdk51.exe



-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: references

2005-07-25 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:

 hello again,
 
 let me clarify my problem.
 
 I have a reference of a subroutine.
 
 eg.
 
 $sub = test;

Better expressed like this:

my $subref = \test;

 ..deref and execute
 
 $sub;
 
 ...
 
 sub test {
 my ($sockethandle,$blah...) = @_;
 ..do something
 }
 
 
 in order to pass the paramenters, i decided to do this : 
 
 sub main {
 
 my $sub = test|$sockethandle;
 ($sub,@_) = split(/\|/,$sub);
 
 $sub;
 }
 
 
 if this is to work correctly, I need to take a socket handle, convert it to a 
 socket ref, then a scaler, so i can pass it as a parameter. in order to use 
 the 
 socket later, i have to take the scaler, convert it to the socket ref, then 
 dereference it.
 
 Is there an easier way to pass parameters with a subroutine reference? 

Just pass a ref rather than concatenating scalar strings together.

use strict;
use warnings;

my $subref = \test;# reference to sub

$subref (\*STDOUT, test args\n); # pass FH ref and string

sub test {
my ($FH, $blah) = @_;

print $FH $blah;

}

__END__

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: voice

2005-07-25 Thread $Bill Luebkert
Sisyphus wrote:

 speak() needs a second argument. Make it:
 
 $voice-speak(hello world, 0);
 
 With that change in place, it works ok for me on Windows 2000.

Works for me with/without a second arg (using 'SAPI.SpVoice' class on XP).

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: references

2005-07-25 Thread John Serink
Why don't you pass the parameters as references.
They work like pointers in C kindof.

Why do you want to reference your subroutine?

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of [EMAIL PROTECTED]
 Sent: Tuesday, July 26, 2005 2:19 AM
 To: $Bill Luebkert
 Cc: perl-win32-users@listserv.ActiveState.com
 Subject: Re: references 
 
 
 hello again,
 
   hello all,
   
   here is a ref/deref problem
   
   I need to take a socket handle, convert it to a socket 
 ref, then a 
   scaler
   string 
   
   A bit later in the same script, I need to take that scaler string 
   and turn
  it
   back to a socket ref, and deref it back to the socket handle.
  
  Maybe instead of asking for the way to implement your solution, you 
  should describe the complete problem and see if we can come 
 up with an 
  alternate solution that is a little less convoluted.  :)
 
 let me clarify my problem.
 
 I have a reference of a subroutine.
 
 eg.
 
 $sub = test;
 
 ..deref and execute
 
 $sub;
 
 ...
 
 sub test {
 my ($sockethandle,$blah...) = @_;
 ..do something
 }
 
 
 in order to pass the paramenters, i decided to do this : 
 
 sub main {
 
 my $sub = test|$sockethandle;
 ($sub,@_) = split(/\|/,$sub);
 
 $sub;
 }
 
 
 if this is to work correctly, I need to take a socket handle, 
 convert it to a 
 socket ref, then a scaler, so i can pass it as a parameter. 
 in order to use the 
 socket later, i have to take the scaler, convert it to the 
 socket ref, then 
 dereference it.
 
 Is there an easier way to pass parameters with a subroutine 
 reference? 
 
 
 
 
 
 
 ___
 Perl-Win32-Users mailing list 
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: references of sub and params in a threads::shared variable

2005-07-25 Thread John Serink
Yup.

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On 
 Behalf Of [EMAIL PROTECTED]
 Sent: Tuesday, July 26, 2005 6:10 AM
 To: Siebe Tolsma
 Cc: perl-win32-users@listserv.ActiveState.com
 Subject: references of sub and params in a threads::shared variable
 
 
 how do i use this hash as a shared variable to be used in 
 threads? eg. with threads::shared
 
 -Jeremy A
 
  Why not make it a hash?
  
  my $sub = { ref = \test, params = [$sockethandle] }; 
  $sub-{ref}-(@{$sub-{params}});
  
  sub test {
  my $socket = shift;
  # ...
  }
  
  
   hello again,
  
 hello all,

 here is a ref/deref problem

 I need to take a socket handle, convert it to a 
 socket ref, then 
 a
  scaler
 string

 A bit later in the same script, I need to take that scaler 
 string and
  turn
it
 back to a socket ref, and deref it back to the socket handle.
   
Maybe instead of asking for the way to implement your solution, 
you
  should
describe the complete problem and see if we can come up with an
  alternate
solution that is a little less convoluted.  :)
  
   let me clarify my problem.
  
   I have a reference of a subroutine.
  
   eg.
  
   $sub = test;
  
   ..deref and execute
  
   $sub;
  
   ...
  
   sub test {
   my ($sockethandle,$blah...) = @_;
   ..do something
   }
   
  
   in order to pass the paramenters, i decided to do this :
  
   sub main {
  
   my $sub = test|$sockethandle;
   ($sub,@_) = split(/\|/,$sub);
  
   $sub;
   }
  
  
   if this is to work correctly, I need to take a socket handle, 
   convert it
  to a
   socket ref, then a scaler, so i can pass it as a 
 parameter. in order 
   to
  use the
   socket later, i have to take the scaler, convert it to the socket 
   ref,
  then
   dereference it.
  
   Is there an easier way to pass parameters with a subroutine 
   reference?
  
  
  
  
  
  
   ___
   Perl-Win32-Users mailing list 
   Perl-Win32-Users@listserv.ActiveState.com
   To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
  
  
  ___
  Perl-Win32-Users mailing list 
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 
 
 
 
 ___
 Perl-Win32-Users mailing list 
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: comparing floating point numbers

2005-07-25 Thread len boyle

Hello Mike

I just saw this site referenced today, they have a large list of other 
sites:



http://www-128.ibm.com/developerworks/library/pa-bigiron1/?ca=dnt-65

Also look at the web site for Mike Cowlishaw who wrote software packages to 
deal with Decimal Floating-Point. See also a Dr Dobbs for an article on this 
with Java by Mike Cowlishaw and a joint author from Sun.


http://www2.hursley.ibm.com/mfcsumm.html

len


- Original Message - 
From: Arms, Mike [EMAIL PROTECTED]
To: Ed Chester [EMAIL PROTECTED]; 
perl-win32-users@listserv.ActiveState.com

Sent: Monday, July 25, 2005 3:39 PM
Subject: RE: comparing floating point numbers




Ed Chester [EMAIL PROTECTED] wrote:

just a warning to be careful of subtracting or dividing similar

numbers in

floating point and what your expectations are for the results. google

for

'catastrophic loss of precision' or similar, or check out the floating

point

standard (IEEE #754) for why these fall apart. *most* tests of

equality, or

relative size, in *most* architectures, map to subtractions by the

time they

get the processor. watch out.


Ed, a cursory look at the search results from Google produced a bunch
of items that specifically referred to the floating point Error in
the first batch of Pentium chips. As this has been corrected, are there
other occurrences of 'catastrophic loss of precision' that can be
tested using modern Pentiums (e.g. II - IV) or AMD chips? Some URLs
would
be helpful here. Thanks.

--
Mike Arms


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: comparing floating point numbers

2005-07-25 Thread robert

-Original Message-
From: James Sluka
Sent: Monday, July 25, 2005 9:11 AM

 Robert's solution (rounding with sprintf) is pretty good, except it 
 requires that you know something about the numbers. 

you are correct about the limitations of floating point accuracy, but in
this case you are making it unnecessarily complicated.  

John (the original poster) is adding a batch of floating point values
that only have two decimal places.  from his specific example, it does
not appear that he needs or wants more accuracy than than the one
one-hundredth place.  

for just two (or three or four or six!) decimal places, he doesnt need
to worry about IEEE floating point standards, or the specifics of his
architecture.   

 For example, they must differ by more than 0.01 to be considered
different. 

not quite.  example, when rounding to nearest 1/100th:

1.104 and 1.105 are different.  
this .001 difference is the minimum that can ever be measured as
different.

1.105 and 1.114 are the same.   
this .009 difference is the maximum that can ever be measured as the
same

certainly there are Other Ways To Do It (tm) -- and probably better
ways to do it -- but this method will always work for these types of
numbers.

...

Finally, if you're trying to do higher math functions that push the
limits of your processor and/or require references to floating point
standards, I'd say you probably shouldnt be using Perl.




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: raj's serial port question

2005-07-25 Thread robert


 -Original Message-
 From: Rajesh Vattem
 Sent: Monday, July 25, 2005 7:21 AM
 
 Hi,
 I am using Win32 serial port APIs in Active perl 5.8.2 for 
 opening COM port. I am getting this error when I open the COM 
 port with a different baud rate
 (eg: 921600). It works fine with baud rate 115200.


921600 ?? is that the speed you are trying to communicate serially at?
Is such a serial port speed even possible, or is that a typo?

at any rate, Win32::SerialPort is limited by its Win32API::CommPort 
dependency, which I am almost certain has a maximum speed of 128K 

I've never seen Win32::SerialPort run at anything faster than 115200.  
and I've had some problems with serial modems over 56K

these modules were stablized about six years ago, and I dont think 
theyve been updated since.  Serial-Port communication is kind of 
trailing-edge technology these days.

--robert





 The way I open the COM port is
 print STDOUT Number of testcases: $ARGV[0]\n;
 
 $config_file = ..\\config\\uelog_port_settings.cfg; #
 uelog_port_settings.cfg contains the 
   
 # configuration parameters for the COM port to 
 $uelog_port_hndle = Win32::SerialPort-start ($config_file) 
or print Can't open Serial 
 port for UE log $config_file; Regards, Rajesh.
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Split function in Perl

2005-07-25 Thread Michael Louie Loria
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hello,

I have a problem with the split function.


string
- - -
one two three four five six seven

should be split to
- - -
one
two three
four five
six
seven


string
- - -
one two three four five six seven

should be split to
- - -
one
two
three
four
five
six
seven


the difference is the string enclosed withis considered as 1
string even with spaces.

Thanks,

Michael Louie Loria
-BEGIN PGP SIGNATURE-
Comment: Public Key: https://www.biglumber.com/x/web?qs=0x4A256EC8
Comment: Public Key: http://www.lorztech.com/GPG.txt
Comment: Yahoo ID: michaellouieloria

iQEVAwUBQuZ7drXBHi2y3jwfAQqL6QgAiROSQrYOyuoITOPNsSxdtYT4VLDeEy6u
LFGQlEcdX2b4nkcPkmNcOEbt6qlnWHjnhQwODEH34+BjIpgAb/7yrIxmlQRPnmnj
/4O4x0YnFa71Gl7jUwythyv3gDeBo12x6GA+SZU/sdNL0IbDGu1qe0aXxEL7dt0I
kveNDhglPqihuWmAG6cqb0CatkV9na9Fg/whsfHbwIGPY4fYCSPi7GzXT+M/K0Mi
yGslp31ibW4ZVWtDm+v6g8dV4RFiKfSSpk8c65S7i384vU0RdhdPMu6Qww2U4PYa
yKdLLZ49XTG7AbMHiF/r6VUMf8rUJ0vE0I83uH1hAGI+x40K2tqiag==
=icS0
-END PGP SIGNATURE-




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: references - inject sub/params into longterm running thread

2005-07-25 Thread mailware
hi there

basically...I have instantiated long term running thread/s.

in the main thread, i want to pass a subroutine (code ref) and its parameters 
into a threads::shared variable, then execute it in a separate thread running 
in a while loop.

I want to do this, because having a group of a couple instantiated long term 
running threads, before processing starts, would be less expensive, then 
instantiated many short term threads for each call...which would be expensive 
and affect performance due to the lag in thread creation.

calls and subroutine's/parameters will vary, so injecting the code into a 
running thread is what i would like.

I hope you all now can understand. Thanks in advance for your help.

Regards,
- Jeremy A. 
 

Quoting John Serink [EMAIL PROTECTED]:

 Why don't you pass the parameters as references.
 They work like pointers in C kindof.
 
 Why do you want to reference your subroutine?




  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On 
  Behalf Of [EMAIL PROTECTED]
  Sent: Tuesday, July 26, 2005 2:19 AM
  To: $Bill Luebkert
  Cc: perl-win32-users@listserv.ActiveState.com
  Subject: Re: references 
  
  
  hello again,
  
hello all,

here is a ref/deref problem

I need to take a socket handle, convert it to a socket 
  ref, then a 
scaler
string 

A bit later in the same script, I need to take that scaler string 
and turn
   it
back to a socket ref, and deref it back to the socket handle.
   
   Maybe instead of asking for the way to implement your solution, you 
   should describe the complete problem and see if we can come 
  up with an 
   alternate solution that is a little less convoluted.  :)
  
  let me clarify my problem.
  
  I have a reference of a subroutine.
  
  eg.
  
  $sub = test;
  
  ..deref and execute
  
  $sub;
  
  ...
  
  sub test {
  my ($sockethandle,$blah...) = @_;
  ..do something
  }
  
  
  in order to pass the paramenters, i decided to do this : 
  
  sub main {
  
  my $sub = test|$sockethandle;
  ($sub,@_) = split(/\|/,$sub);
  
  $sub;
  }
  
  
  if this is to work correctly, I need to take a socket handle, 
  convert it to a 
  socket ref, then a scaler, so i can pass it as a parameter. 
  in order to use the 
  socket later, i have to take the scaler, convert it to the 
  socket ref, then 
  dereference it.
  
  Is there an easier way to pass parameters with a subroutine 
  reference? 
  
  
  
  
  
  
  ___
  Perl-Win32-Users mailing list 
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Split function in Perl

2005-07-25 Thread Darrell Gammill
http://search.cpan.org/~nwclark/perl-5.8.7/lib/Text/ParseWords.pm

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Michael Louie Loria
Sent: Monday, July 25, 2005 9:57 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Split function in Perl


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hello,

I have a problem with the split function.


string
- - -
one two three four five six seven

should be split to
- - -
one
two three
four five
six
seven


string
- - -
one two three four five six seven

should be split to
- - -
one
two
three
four
five
six
seven


the difference is the string enclosed withis considered as 1
string even with spaces.

Thanks,

Michael Louie Loria
-BEGIN PGP SIGNATURE-
Comment: Public Key: https://www.biglumber.com/x/web?qs=0x4A256EC8
Comment: Public Key: http://www.lorztech.com/GPG.txt
Comment: Yahoo ID: michaellouieloria

iQEVAwUBQuZ7drXBHi2y3jwfAQqL6QgAiROSQrYOyuoITOPNsSxdtYT4VLDeEy6u
LFGQlEcdX2b4nkcPkmNcOEbt6qlnWHjnhQwODEH34+BjIpgAb/7yrIxmlQRPnmnj
/4O4x0YnFa71Gl7jUwythyv3gDeBo12x6GA+SZU/sdNL0IbDGu1qe0aXxEL7dt0I
kveNDhglPqihuWmAG6cqb0CatkV9na9Fg/whsfHbwIGPY4fYCSPi7GzXT+M/K0Mi
yGslp31ibW4ZVWtDm+v6g8dV4RFiKfSSpk8c65S7i384vU0RdhdPMu6Qww2U4PYa
yKdLLZ49XTG7AbMHiF/r6VUMf8rUJ0vE0I83uH1hAGI+x40K2tqiag==
=icS0
-END PGP SIGNATURE-




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: references - inject sub/params into longterm running thread

2005-07-25 Thread John Serink
If you use shared arrays or hashes, Win32 perl will leak handles if you
use threads.
It will leak 2 handles per thread. If you're only starting say a couple
of threads an hour, no problem. If you're starting hindreds, within a
week or so, you'll run out of resource space for the process and it will
crash.

The leaking handles is a known bug when using threads on Win32.

Cheers,
John

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, July 26, 2005 11:20 AM
 To: perl-win32-users@listserv.ActiveState.com
 Cc: John Serink
 Subject: RE: references - inject sub/params into longterm 
 running thread
 
 
 hi there
 
 basically...I have instantiated long term running thread/s.
 
 in the main thread, i want to pass a subroutine (code ref) 
 and its parameters 
 into a threads::shared variable, then execute it in a 
 separate thread running 
 in a while loop.
 
 I want to do this, because having a group of a couple 
 instantiated long term 
 running threads, before processing starts, would be less 
 expensive, then 
 instantiated many short term threads for each call...which 
 would be expensive 
 and affect performance due to the lag in thread creation.
 
 calls and subroutine's/parameters will vary, so injecting the 
 code into a 
 running thread is what i would like.
 
 I hope you all now can understand. Thanks in advance for your help.
 
 Regards,
 - Jeremy A. 
  
 
 Quoting John Serink [EMAIL PROTECTED]:
 
  Why don't you pass the parameters as references.
  They work like pointers in C kindof.
  
  Why do you want to reference your subroutine?
 
 
 
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On 
   Behalf Of [EMAIL PROTECTED]
   Sent: Tuesday, July 26, 2005 2:19 AM
   To: $Bill Luebkert
   Cc: perl-win32-users@listserv.ActiveState.com
   Subject: Re: references 
   
   
   hello again,
   
 hello all,
 
 here is a ref/deref problem
 
 I need to take a socket handle, convert it to a socket
   ref, then a
 scaler
 string
 
 A bit later in the same script, I need to take that scaler 
 string
 and turn
it
 back to a socket ref, and deref it back to the socket handle.

Maybe instead of asking for the way to implement your solution, 
you
should describe the complete problem and see if we can come 
   up with an
alternate solution that is a little less convoluted.  :)
   
   let me clarify my problem.
   
   I have a reference of a subroutine.
   
   eg.
   
   $sub = test;
   
   ..deref and execute
   
   $sub;
   
   ...
   
   sub test {
   my ($sockethandle,$blah...) = @_;
   ..do something
   }
   
   
   in order to pass the paramenters, i decided to do this :
   
   sub main {
   
   my $sub = test|$sockethandle;
   ($sub,@_) = split(/\|/,$sub);
   
   $sub;
   }
   
   
   if this is to work correctly, I need to take a socket handle,
   convert it to a 
   socket ref, then a scaler, so i can pass it as a parameter. 
   in order to use the 
   socket later, i have to take the scaler, convert it to the 
   socket ref, then 
   dereference it.
   
   Is there an easier way to pass parameters with a subroutine
   reference? 
   
   
   
   
   
   
   ___
   Perl-Win32-Users mailing list
   Perl-Win32-Users@listserv.ActiveState.com
   To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
   
  
 
 
 
 
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: references - inject sub/params into longterm running thread

2005-07-25 Thread $Bill Luebkert
[EMAIL PROTECTED] wrote:

 hi there
 
 basically...I have instantiated long term running thread/s.
 
 in the main thread, i want to pass a subroutine (code ref) and its parameters 
 into a threads::shared variable, then execute it in a separate thread running 
 in a while loop.
 
 I want to do this, because having a group of a couple instantiated long term 
 running threads, before processing starts, would be less expensive, then 
 instantiated many short term threads for each call...which would be expensive 
 and affect performance due to the lag in thread creation.
 
 calls and subroutine's/parameters will vary, so injecting the code into a 
 running thread is what i would like.
 
 I hope you all now can understand. Thanks in advance for your help.

We're getting closer.  Now create a proper test snippet that uses threads
and we'll see if we can help where it fails.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: raj's serial port question

2005-07-25 Thread robert

 -Original Message-
 From: Rajesh Vattem 
 Sent: Monday, July 25, 2005 9:19 PM
 
 
 Hi Robert,
 If you open a hyper terminal and see the baud rate supported 
 you can see that 921600 is a supported value. If I use a USB 
 to serial converter to support such speed, is there any perl 
 module which I can use? Thanks for your time, Regards, Rajesh


Hi Rajesh, yes you're right:  921600 sure is supported by hyperterminal
on WinXP.  i only use serial communication on Win98 machines at work,
and i dont remember ever seeing it that high.

anyhow, im still pretty sure the Win32API perl module only supports 128K
maximum.   

I see there is a Device::USB module on CPAN, but it appears to be very
recent and the only review available says it failed installation.
whats more, it appears to be dependent on a certain libusb package
which is still in development *and* Linux-specific.

my only experience with USB/Serial converters has been one of
frustration, but admittedly i never really worked with it much.

so...  I think you will have a difficult time, but maybe it is possible.
The only thing i can say for certain is that I Really Have No Idea.
Sorry  :-(

I am posting this back the the Win32-Users distribution list, because I
hope that maybe someone else will have more experience in this area, and
they can help you. 

Good luck to you, I know how frustrating these things can be.  --robert



 
 -Original Message-
 From: robert 
 Sent: Tuesday, July 26, 2005 7:53 AM
 
  -Original Message-
  From: Rajesh Vattem
  Sent: Monday, July 25, 2005 7:21 AM
  
  Hi,
  I am using Win32 serial port APIs in Active perl 5.8.2 for
  opening COM port. I am getting this error when I open the COM 
  port with a different baud rate
  (eg: 921600). It works fine with baud rate 115200.
 
 
 921600 ?? is that the speed you are trying to communicate serially at?
 Is such a serial port speed even possible, or is that a typo?
 
 at any rate, Win32::SerialPort is limited by its Win32API::CommPort 
 dependency, which I am almost certain has a maximum speed of 128K 
 
 I've never seen Win32::SerialPort run at anything faster than 
 115200.  
 and I've had some problems with serial modems over 56K
 
 these modules were stablized about six years ago, and I dont think 
 theyve been updated since.  Serial-Port communication is kind of 
 trailing-edge technology these days.
 
 --robert
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Split function in Perl

2005-07-25 Thread robert


 -Original Message-
 From: $Bill Luebkert
 Sent: Monday, July 25, 2005 9:30 PM
  
 s/([^]+) ([^]+)/$1\000$2/g;   


holy cow.  can you explain that substitution?   my brain just about
popped.




 
 my @a = split / +/;
 
 foreach (@a) {
   s/\000/ /g; # restore embedded spaces
   print $_\n;
 }
 
 __END__
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs