[27867] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9231 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 16 21:05:45 2006

Date: Tue, 16 May 2006 18:05:03 -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           Tue, 16 May 2006     Volume: 10 Number: 9231

Today's topics:
    Re: "Wide character in syswrite" in writing an HTML for <flavell@physics.gla.ac.uk>
    Re: Compiling and Installing Perl <bart.lateur@pandora.be>
        Integer overflow in Excel using Win32::OLE niall.macpherson@ntlworld.com
    Re: Integer overflow in Excel using Win32::OLE <1usa@llenroc.ude.invalid>
        Perl :: Telnet Status of Machine <kuldeepchitrakar@gmail.com>
    Re: Perl :: Telnet Status of Machine <1usa@llenroc.ude.invalid>
        simple script <gary.larson@gmx.at>
    Re: simple script <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 16 May 2006 12:13:03 +0100
From: "Alan J. Flavell" <flavell@physics.gla.ac.uk>
Subject: Re: "Wide character in syswrite" in writing an HTML form.
Message-Id: <Pine.LNX.4.64.0605160909190.27666@ppepc20.ph.gla.ac.uk>

On Tue, 16 May 2006, Ben Bullock wrote:

> funny thing is that I've been using that script since last July to 
> send utf8 encoded Japanese characters, and hadn't had a problem with 
> it. 

Interesting.

> The mangled stuff was things like pound signs and unicode half 
> signs.

You didn't say that before, and there might be something significant 
in the detail.  Witness this earlier discussion:

|> > Also, I have had some characters mangled.
|
|> Sorry, but this is not a useful report!
|
|Hmm? Some non-ascii UTF8 characters got mangled  [...]

and compare it with the new information which you now provided.

On the basis of that new information, I'd say there's a possibility 
that the code does not realise that it needs to use the utf8 
representation, unless the characters are above 255.

-- 

  luser asked for an agronomic keyboard...


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

Date: Tue, 16 May 2006 10:16:07 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Compiling and Installing Perl
Message-Id: <7d9j62lrc31rdvlk6r3o9n48snmoedvgih@4ax.com>

Paul Lalli wrote:

>If not, the most standard Windows distribution of Perl is produced by
>ActiveState, and can be found at
 ...

For a more complete list of alternatives, check out
Camelpack/VanillaPerl, at
<http://camelpack.sourceforge.net/index.php/Main_Page>

There's an attempt at a complete overview at
<http://camelpack.sourceforge.net/index.php/Other_Perl_Installers>.

-- 
	Bart.


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

Date: 16 May 2006 03:35:33 -0700
From: niall.macpherson@ntlworld.com
Subject: Integer overflow in Excel using Win32::OLE
Message-Id: <1147775733.225942.248650@i40g2000cwc.googlegroups.com>

I am using  Win32::OLE to output data to an Excel Spreadsheet.

However I am finding that all integers between 2e31 and 2e32 are
displayed incorrectly. I get a negative number (can't remember whether
it is 1s complement or 2s complement :( )

Printing the data using Data::Dumper results in the correct values
being shown.

The problem disappears when the value reaches 2e32.

Sample code

##---------------------------------------------------------------------
use strict;
use warnings;
use Win32::OLE;
use Data::Dumper;

##---------------------------------------------------------------------
sub ConnectToExcel
{
	my $excel_conn;
	eval
	{
		## check if already running
		$excel_conn = Win32::OLE->GetActiveObject('Excel.Application')
	};
	die "Excel not installed" if $@;

	unless (defined $excel_conn)
	{
		## if not , run it
		## TODO Check what the $_[0]->Quit is about
		$excel_conn = Win32::OLE->new('Excel.Application', sub
{$_[0]->Quit;})
		or die "Failed to start Excel";
	}
	return($excel_conn);
}
##---------------------------------------------------------------------
my $excel_conn = ConnectToExcel();
my $work_book = $excel_conn->Workbooks->Add;
my $work_sheet = $work_book->Worksheets(1);

my $data = 1;
for(my $lcount = 29; $lcount <= 33; $lcount++)
{
	my $data = (2 ** $lcount);
	print Dumper "Adding $data ";
	$work_sheet->Cells($lcount - 28, 1)->{Value} =  $lcount;
	$work_sheet->Cells($lcount - 28, 2)->{Value} =  $data;
	$work_sheet->Cells($lcount - 28, 3)->{Value} =  $data + 1;
	$work_sheet->Cells($lcount - 28, 4)->{Value} =  $data - 1;
}
exit(0);

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

Output from Data::Dumper

C:\develop\NiallPerlScripts>excel_bigint.pl
$VAR1 = 'Adding 536870912 ';
$VAR1 = 'Adding 1073741824 ';
$VAR1 = 'Adding 2147483648 ';
$VAR1 = 'Adding 4294967296 ';
$VAR1 = 'Adding 8589934592 ';

Values from the excel spreadsheet

29	536870912	536870913	536870911
30	1073741824	1073741825	1073741823
31	-2147483648	-2147483647	2147483647
32	4294967296	4294967297	4294967295
33	8589934592	8589934593	8589934591


Note the values for (2**31) and (2**31)+1 are incorrect. However
(2**31)-1 and (2**32) are displayed correctly.

Am I missing something I need to use here ? (Math::Bigint possibly - I
have seen it referred to before but never used it), or is it a bug in
the Win32::OLE module ?

Thanks



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

Date: Tue, 16 May 2006 11:41:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Integer overflow in Excel using Win32::OLE
Message-Id: <Xns97C54E370E044asu1cornelledu@127.0.0.1>

niall.macpherson@ntlworld.com wrote in
news:1147775733.225942.248650@i40g2000cwc.googlegroups.com: 

> I am using  Win32::OLE to output data to an Excel Spreadsheet.
> 
> However I am finding that all integers between 2e31 and 2e32 are
> displayed incorrectly. I get a negative number (can't remember whether
> it is 1s complement or 2s complement :( )

On two's complement machines, signed integer of size n are recognized by 
the MSB being set.

So, for an 

8  bit signed int, the value 0x80          (128)     is -1
16 bit signed int, the value 0x8000       (32768)    is -1
32 bit signed int, the value 0x80000000 (2147483648) is -1

> Printing the data using Data::Dumper 

Yeah, about that, what is the point of using Data::Dumper to print a 
simple string?

 ##---------------------------------------------------------------------
> use strict;
> use warnings;

Thank you for posting a small self-contained script which is strict and 
warnings clean. Much appreciated.

> my $data = 1;
> for(my $lcount = 29; $lcount <= 33; $lcount++)
> {
>      my $data = (2 ** $lcount);
>      print Dumper "Adding $data ";
>      $work_sheet->Cells($lcount - 28, 1)->{Value} =  $lcount;
>      $work_sheet->Cells($lcount - 28, 2)->{Value} =  $data;
>      $work_sheet->Cells($lcount - 28, 3)->{Value} =  $data + 1;
>      $work_sheet->Cells($lcount - 28, 4)->{Value} =  $data - 1;
> }
> exit(0);
> 
 ...
> Output from Data::Dumper
> 
> C:\develop\NiallPerlScripts>excel_bigint.pl
> $VAR1 = 'Adding 536870912 ';
> $VAR1 = 'Adding 1073741824 ';
> $VAR1 = 'Adding 2147483648 ';
> $VAR1 = 'Adding 4294967296 ';
> $VAR1 = 'Adding 8589934592 ';
> 
> Values from the excel spreadsheet
> 
> 29     536870912     536870913     536870911
> 30     1073741824     1073741825     1073741823
> 31     -2147483648     -2147483647     2147483647
> 32     4294967296     4294967297     4294967295
> 33     8589934592     8589934593     8589934591
> 
> 
> Note the values for (2**31) and (2**31)+1 are incorrect. However
> (2**31)-1 and (2**32) are displayed correctly.

 ...

> is it a bug in the Win32::OLE module ?

I would not regard it as a bug. It is a boundary condition with 32-bit 
integers. Simply sending the numbers to Excel as strings yields the 
correct display (after setting the cell format to Number with 0 decimal 
digits):

$excel->{Visible} = 1;

my $data = 1;

for(my $lcount = 29; $lcount <= 33; $lcount++) {
    my $data = (2 ** $lcount);
    warn sprintf "%s\t%s\t%s\n", $data, $data + 1, $data - 1;
    $sheet->Cells($lcount - 28, 1)->{Value} =  "$lcount";
    $sheet->Cells($lcount - 28, 2)->{Value} =  "$data";
    $sheet->Cells($lcount - 28, 3)->{Value} =  "@{ [ $data + 1 ] }";
    $sheet->Cells($lcount - 28, 4)->{Value} =  "@{ [ $data - 1 ] }";
}

D:\Home\asu1\UseNet\clpmisc> bbb
536870912       536870913       536870911
1073741824      1073741825      1073741823
2147483648      2147483649      2147483647
4294967296      4294967297      4294967295
8589934592      8589934593      8589934591

From Excel:

29	536870912	536870913	536870911
30	1073741824	1073741825	1073741823
31	2147483648	2147483649	2147483647
32	4294967296	4294967297	4294967295
33	8589934592	8589934593	8589934591

Sinan
-- 
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: 16 May 2006 04:52:08 -0700
From: "Kuldeep" <kuldeepchitrakar@gmail.com>
Subject: Perl :: Telnet Status of Machine
Message-Id: <1147780327.985931.321180@i40g2000cwc.googlegroups.com>

Hi
  How can we get to know whether we can telnet to machine or not!
I am using.

Net::Telnet



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

Date: Tue, 16 May 2006 11:53:46 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl :: Telnet Status of Machine
Message-Id: <Xns97C5505A5C87Fasu1cornelledu@127.0.0.1>

"Kuldeep" <kuldeepchitrakar@gmail.com> wrote in 
news:1147780327.985931.321180@i40g2000cwc.googlegroups.com:

>   How can we get to know whether we can telnet to machine or not!
> I am using.
> 
> Net::Telnet

Try to connect and see if it works.

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

Date: 16 May 2006 04:41:49 -0700
From: "josef hader" <gary.larson@gmx.at>
Subject: simple script
Message-Id: <1147779708.368030.100740@v46g2000cwv.googlegroups.com>

Hello,
I would like to apply e.g. epstopdf to several files specified e.g by
*.eps
I have writen the following perl program, however it does not work
(resolve the joker)

#! /usr/bin/perl -w
foreach @argnum (0 .. $#ARGV) {
   print "$ARGV[$argnum]\n";
   epstopdf $ARGV[$argnum];
}

thanks!



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

Date: Tue, 16 May 2006 11:51:37 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: simple script
Message-Id: <Xns97C54FFD0E58Fasu1cornelledu@127.0.0.1>

"josef hader" <gary.larson@gmx.at> wrote in 
news:1147779708.368030.100740@v46g2000cwv.googlegroups.com:

> I would like to apply e.g. epstopdf to several files specified e.g by
> *.eps
> I have writen the following perl program, however it does not work
> (resolve the joker)

No, we should not have to figure it out. You need to show what you 
expected and what you got.

> #! /usr/bin/perl -w

use strict;

missing.

> foreach @argnum (0 .. $#ARGV) {

Why @argnum?

>    print "$ARGV[$argnum]\n";
>    epstopdf $ARGV[$argnum];

$argnum is undeclared.

There is no Perl function called epstopdf.

perldoc -f system

> thanks!

Please read the posting guidelines for this group, and follow them.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



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

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 V10 Issue 9231
***************************************


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