[28757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 5 21:05:59 2007

Date: Fri, 5 Jan 2007 18:05:11 -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 Jan 2007     Volume: 11 Number: 1

Today's topics:
    Re: Elegant equivalent to this regex? <foobarbazqux@hotmail.com>
    Re: Elegant equivalent to this regex? <john@castleamber.com>
        is Perl used in the Java middle-tier andrew_nuss@yahoo.com
    Re: is Perl used in the Java middle-tier <cwilbur@chromatico.net>
    Re: is Perl used in the Java middle-tier <snob@pense-mainz.eu>
    Re: is Perl used in the Java middle-tier andrew_nuss@yahoo.com
    Re: is Perl used in the Java middle-tier <snob@pense-mainz.eu>
    Re: is Perl used in the Java middle-tier <brian.d.foy@gmail.com>
    Re: Math::GMP make test fails. <stahl.karl@gmail.com>
        Net::SSH installation problems - how do I force local p <stahl.karl@gmail.com>
        network simulator - NS2 <dpsilvaengcomp@gmail.com>
    Re: network simulator - NS2 usenet@DavidFilmer.com
    Re: OSCON 2006 - Perl programming vs. scripting <Peter@PSDT.com>
    Re: OSCON 2006 - Perl programming vs. scripting <uri@stemsystems.com>
        stalling server client program <deadpickle@gmail.com>
    Re: Unsecured scripts and site hacking? <tzz@lifelogs.com>
    Re: using Perl to find string.. <tzz@lifelogs.com>
        Win32::OLE - saving content of just one worksheet in Ex <woland99@gmail.com>
    Re: Win32::OLE - saving content of just one worksheet i <woland99@gmail.com>
    Re: Win32::OLE - saving content of just one worksheet i <brian.helterline@hp.com>
    Re: Win32::OLE - saving content of just one worksheet i <woland99@gmail.com>
        Writing a UTF-8 file <michael_perle@yahoo.com>
    Re: Writing a UTF-8 file <scobloke2@infotop.co.uk>
    Re: Writing UTF-8 file under Windows <ben.usenet@bsb.me.uk>
    Re: Writing UTF-8 file under Windows <scobloke2@infotop.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 5 Jan 2007 15:00:07 -0800
From: "foo bar baz qux" <foobarbazqux@hotmail.com>
Subject: Re: Elegant equivalent to this regex?
Message-Id: <1168038006.923938.103460@q40g2000cwq.googlegroups.com>

Purl Gurl AKA Godzilla AKA Callgirl AKA Kiralynne Schilitubi wrote:

> Benchmark: timing 1000000 iterations of PurlGurl, Uri...
>    PurlGurl:  2 wallclock secs ( 1.87 usr +  0.00 sys =  1.87 CPU) @ 534759.36/s(n=1000000)
>         Uri:  3 wallclock secs ( 3.08 usr +  0.00 sys =  3.08 CPU) @ 324675.32/s(n=1000000)

PG still has a pointless obsession with microsecond differences.


> Easy for readers to surmise use of lexical declarations on
> a global scale reduces script efficiency an average of
> thirty-three percent, for this specific case example.

Typically verbose, PG takes 27 words to say "1.87 is 33% less than
3.08".

Maybe PG should have spent more time on the pertinent arithmetic and
less on the otiose wordage.


Soon there may be paranoid accusations and tales of farm life.


Purl Gurl rants include ...

"over these many years regulars in this group have directed at me,
insults, racial slurs, threats of physical violence, threats of death,
have tried a million times to crash my server and, of course, troll me
everyday"
- Purl Gurl, Oct 26 2005


"You of the Perl Community, have successfully given the Perl Community
a reputation of being populated by mentally disturbed people who are
psychotically driven to harass all peoples, children, women, men, the
elderly, all people, about whom you know nothing. "
- Purl Gurl, Jun 27 2004


"... a huge mule's ass I once plowed behind as a child. I looked up,
way up cuz that mule stood eighty hands high"
- Purl Gurl, Oct a6 2005

>> that mule stood eighty hands high
> Really?  80 hands = 80 x 4 inches = 320 inches = 26 feet 8 inches.
> You cannot expect us to believe your mule was nearly 27 feet tall.
- Joe Smith,  Oct 16 2005

Hmm, arithmetic may be a long standing weakness of PG.


"Use of "our" and "my" for globals serves no purpose. "
- Purl Gurl, Oct 15 2005

#!perl
# Written by Purl Gurl
 ...
our %in;
- Ken Singleton, Jul 7 2004



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

Date: 6 Jan 2007 00:03:39 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Elegant equivalent to this regex?
Message-Id: <Xns98AFB7B90534Acastleamber@130.133.1.4>

"foo bar baz qux" <foobarbazqux@hotmail.com> wrote:

> Purl Gurl rants include ...

Bokma H4x0r'd my b0x!
You are all male sexists picking on Abigail and me

Or something along those lines :-D

-- 
John                Experienced Perl programmer: http://castleamber.com/

          Perl help, tutorials, and examples: http://johnbokma.com/perl/


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

Date: 5 Jan 2007 06:49:02 -0800
From: andrew_nuss@yahoo.com
Subject: is Perl used in the Java middle-tier
Message-Id: <1168008542.371438.287150@i15g2000cwa.googlegroups.com>

Hi,

I'm a newbie at regexes and a professional java programmer.  I've ready
Friedl's book and see that
java.util.regex is missing code assertions and overall can't solve the
complexity of matching, transformation
problems that Perl can solve.  Therefore, I'm wondering if there are
companies that are integrating Perl
solutions into their enterprise java applications.  Or do they just
struggle with java.util.regex.

Andy



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

Date: 05 Jan 2007 10:37:21 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: is Perl used in the Java middle-tier
Message-Id: <878xghwklq.fsf@mithril.chromatico.net>

>>>>> "an" == andrew nuss <andrew_nuss@yahoo.com> writes:

    an> Therefore, I'm wondering if there are companies that are
    an> integrating Perl solutions into their enterprise java
    an> applications.  Or do they just struggle with java.util.regex.

I don't know of any; generally, any company that's smart enough to
comprehend that Perl can be more expressive than Java generally isn't
using Java for enterprise applications.

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Fri, 5 Jan 2007 17:22:55 +0100
From: Joachim Pense <snob@pense-mainz.eu>
Subject: Re: is Perl used in the Java middle-tier
Message-Id: <qmoaiggvipn3.8ovp0xt07dsq.dlg@40tude.net>

Am 5 Jan 2007 06:49:02 -0800 schrieb andrew_nuss@yahoo.com:

> Hi,
> 
> I'm a newbie at regexes and a professional java programmer.  I've ready
> Friedl's book and see that
> java.util.regex is missing code assertions and overall can't solve the
> complexity of matching, transformation
> problems that Perl can solve.  Therefore, I'm wondering if there are
> companies that are integrating Perl
> solutions into their enterprise java applications.  Or do they just
> struggle with java.util.regex.
> 
> Andy

Use C#. Then you have regexes with Perl's complexity (of course
without Perl's elegance, but you're used to that being a Java
programmer).

Joachim


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

Date: 5 Jan 2007 09:42:27 -0800
From: andrew_nuss@yahoo.com
Subject: Re: is Perl used in the Java middle-tier
Message-Id: <1168018947.208489.229000@11g2000cwr.googlegroups.com>


>
> Use C#. Then you have regexes with Perl's complexity (of course
> without Perl's elegance, but you're used to that being a Java
> programmer).
> 

Does C# have code assertions?



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

Date: Fri, 5 Jan 2007 23:48:20 +0100
From: Joachim Pense <snob@pense-mainz.eu>
Subject: Re: is Perl used in the Java middle-tier
Message-Id: <1t1xz4r5altxt$.7rocefirymw8$.dlg@40tude.net>

Am 5 Jan 2007 09:42:27 -0800 schrieb andrew_nuss@yahoo.com:

>>
>> Use C#. Then you have regexes with Perl's complexity (of course
>> without Perl's elegance, but you're used to that being a Java
>> programmer).
>> 
> 
> Does C# have code assertions?

I'm not an expert, but googling leads me to the answer "yes".


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

Date: Fri, 05 Jan 2007 20:01:55 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: is Perl used in the Java middle-tier
Message-Id: <050120072001559591%brian.d.foy@gmail.com>

In article <1168008542.371438.287150@i15g2000cwa.googlegroups.com>,
<andrew_nuss@yahoo.com> wrote:


> I'm a newbie at regexes and a professional java programmer.  I've ready
> Friedl's book and see that
> java.util.regex is missing code assertions and overall can't solve the
> complexity of matching, transformation
> problems that Perl can solve. 

Have you run into a situation where you needed the missing features?
Perl's regex engine has a lot of nifty tools, but if you don't need
them it doesn't really matter if they are missing from Java. :)

-- 
Posted via a free Usenet account from http://www.teranews.com



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

Date: 5 Jan 2007 10:29:55 -0800
From: "Ishmael" <stahl.karl@gmail.com>
Subject: Re: Math::GMP make test fails.
Message-Id: <1168021795.738737.217880@38g2000cwa.googlegroups.com>

Thank you for the very helpful and incredibly prompt response.
Everything compiled beautifully.

In case someone else reads this, I should mention one other problem
that I had to solve before this package finally passed 'make test'.
The problem comes from the compilation of the C gmp package that the
Perl code rests on.  While that compilation came up error-free on my
machine (even after running 'make check'), when I ran 'make test' from
the Perl package, I ended up with errors along the lines of the
following:

ld: fatal: file /home/kstahl/PERL/gmp-4.2.1/lib/libgmp.so: wrong ELF
class:
ELFCLASS64

These problems apparently stem from incompatibilities in the libraries.
 I am running on a Unix platform with Solaris 5.8 and perl 5.6.1.  I
don't know what exactly the problem is, but the solution is to compile
gmp in 32 bit mode, but adding the ABI=32 option when running
configure.  After doing this, the Perl module compiled error-free.



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

Date: 5 Jan 2007 14:06:28 -0800
From: "Ishmael" <stahl.karl@gmail.com>
Subject: Net::SSH installation problems - how do I force local path?
Message-Id: <1168034787.811637.12740@38g2000cwa.googlegroups.com>

I'm trying to install Net::SSH locally (not as root), but I'm having
trouble getting Make to recognize the paths to the required (also
locally installed) packages.

Here's what I'm doing.  First, I create the Makefile.

   perl Makefile.PL PREFIX=/home/kstahl/PERL/Net-SSH-Perl-1.30

** Note that I have edited Makefile.PL by adding the following line (in
the hopes that at least it will find my local version of GMP:

   LIBS => ['-L/home/kstahl/PERL/Math-GMP-2.04/'],

The messages I then get are not promising.  Still, the warnings below I
think are created by trying to run 'use mypackage' and then capturing
the error messages, and since 'use' doesn't know about my local
installation of GMP, the error doesn't mean much.

   ...
   Checking if your kit is complete...
   Looks good
   Warning: prerequisite Digest::SHA1 2.10 not found. We have 2.04.
   Warning: prerequisite Math::GMP 1.04 not found.
   Warning: prerequisite Scalar::Util 0 not found.
   Writing Makefile for Net::SSH::Perl

Now 'make' doesn't give any errors, but 'make test' gives the following
(excerpt):

   PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e"

   "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
   t/01-compile.....dubious

        Test returned status 1 (wstat 256, 0x100)
   DIED. FAILED test 1
        Failed 1/1 tests, 0.00% okay
   t/02-buffer......Can't load

'/apps/gnu/perl_local/lib/site_perl/5.6.1/sol2.sun4/auto/Math/GMP/GMP.so'
for
   module Math::GMP: ld.so.1: /usr/local/bin/perl: fatal: libgmp.so.3:
open failed:
   No such file or directory at
/apps/gnu/perl-5.6.1/lib/sol2.sun4/DynaLoader.pm
   line 206.
    at t/02-buffer.t line 9
   Compilation failed in require at t/02-buffer.t line 9.
   BEGIN failed--compilation aborted at t/02-buffer.t line 9.
   ...

As I read it, the compiler is looking for GMP.so in the Perl
installation directory, but that's not where it is - it's in my local
directory.  How can I force the compiler to look in the right place?
Thanks a million for your help.



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

Date: 5 Jan 2007 10:14:30 -0800
From: "giantpassos" <dpsilvaengcomp@gmail.com>
Subject: network simulator - NS2
Message-Id: <1168020870.801442.202020@51g2000cwl.googlegroups.com>

Hi Everybody,

Who had already worked with network simulator(NS2). Please, mail me
some examples of perl script and gnuplot file commands used to
calculater throughput, jitter and end-to-end delay.

Regards,

Diego Passos.



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

Date: 5 Jan 2007 10:23:12 -0800
From: usenet@DavidFilmer.com
Subject: Re: network simulator - NS2
Message-Id: <1168021392.766339.241200@51g2000cwl.googlegroups.com>

giantpassos wrote:
[snip multiposted article]

Please do not multipost.

--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)



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

Date: Fri, 05 Jan 2007 15:46:32 GMT
From: Peter Scott <Peter@PSDT.com>
Subject: Re: OSCON 2006 - Perl programming vs. scripting
Message-Id: <pan.2007.01.05.15.46.28.454765@PSDT.com>

On Thu, 04 Jan 2007 13:49:29 -0800, usenet wrote:
> This may be a little bit OT, and probably a long shot...
> 
> I attended the Lightning Talks session of OSCON 2006 (in July).  My
> memory is a little fuzzy...
> 
> A well-known Perl guru (I think it might have been Peter Scott) did a
> brief presentation encouraging folks to describe of Perl as a
> programming language rather than a scripting language.  He used a whole
> slew of examples to show why (closures, methods, etc).
> 
> Now, months later, I'm interested in getting a copy of that
> presentation.  I don't suppose anybody here would know where I might
> get it?

Sorry, no, it wasn't me.  I believe you want Uri Guttman.

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/



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

Date: Fri, 05 Jan 2007 11:31:20 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: OSCON 2006 - Perl programming vs. scripting
Message-Id: <x7bqldcu5j.fsf@mail.sysarch.com>

>>>>> "PS" == Peter Scott <Peter@PSDT.com> writes:

  PS> On Thu, 04 Jan 2007 13:49:29 -0800, usenet wrote:
  >> This may be a little bit OT, and probably a long shot...
  >> 
  >> I attended the Lightning Talks session of OSCON 2006 (in July).  My
  >> memory is a little fuzzy...
  >> 
  >> A well-known Perl guru (I think it might have been Peter Scott) did a
  >> brief presentation encouraging folks to describe of Perl as a
  >> programming language rather than a scripting language.  He used a whole
  >> slew of examples to show why (closures, methods, etc).
  >> 
  >> Now, months later, I'm interested in getting a copy of that
  >> presentation.  I don't suppose anybody here would know where I might
  >> get it?

  PS> Sorry, no, it wasn't me.  I believe you want Uri Guttman.

'twasn't me! my lightning talk was on the precursor to
Template::Simple. and the OP knows me directly anyhow.

best to ask the lightning moderator (mjd or geoff avery) for a list of
the talks for that oscon. i vaguely recall a talk that was about calling
perl a programming lang and not a scripting one. it wouldn't be too hard
to just whip up a few points like that, especially using any shell as a
baseline to compare against.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 5 Jan 2007 17:37:24 -0800
From: "deadpickle" <deadpickle@gmail.com>
Subject: stalling server client program
Message-Id: <1168047444.311981.54020@s80g2000cwa.googlegroups.com>

This program is designed to transfer a file to a client. When i go to
run the program It sends the file once then sits there. The file that
is sent is not closed and there fore conatins no data. I'm not sure
what the problem is.

client
=================================
for (;;) {
use strict;
use IO::Socket;
$|=1;
my $host = shift || '192.168.1.100';
my $port = shift || '7890';
my $sock = new IO::Socket::INET(
             PeerAddr => $host,
             PeerPort => $port,
             Proto    => 'tcp');
$sock or die "no socket :$!";
#--------------/ Socket opened \----------------

my $filename = 'L:\School\Meteorology\UAV\uavposition.txt'; # the file
to be sent by the server side
my $fileout = 'C:\uavposition.txt'; # the file in which we should place
received datas
unless (open (FH_RECEPTION, ">",  $fileout)){
         die "Unable to create $fileout $!";
        }

print $sock "FILE|$filename\n";
my @elem=();
my $all_received;
while (my $line=<$sock>){
         chomp($line);
        #
        # Remove the next line in production
        #
         print "RECEIVED>$line\n";
         @elem = split /\|/, $line;
         if ($line=~/^FIL\|/){
                 $elem[1]='' unless (defined $elem[1]);
                 print FH_RECEPTION $elem[1]."\n";
                 $all_received=0;
         }
         elsif ($line=~/^EOT\|/){
                 print "Normal End of Transmission received\n";
                 $all_received=1;
                 last;
         }
         elsif ($line=~/^NACK\|/){
                 print "ERROR: $elem[1]\n";
                 last;
         }
         else {
                 print "Do not understand|$line\n";
                 last;
         }
}
close($sock);
close(FH_RECEPTION);
 if ((defined $all_received) and ($all_received==1)){
         print "Everything has been received in $fileout\n";
}

elsif (defined $all_received) {
         print "some part of the file has been received in $fileout\n";
}
sleep (5);
}
exit;

Server
===============================
use strict;
use IO::Socket;
my $sock = new IO::Socket::INET(
                   LocalPort => '7890',  #port to bind socket to
                   Proto     => 'tcp',
                   Listen    => SOMAXCONN,
                   Reuse     => 1);
$sock or die "no socket :$!";
my($new_sock, $c_addr, $buf);
while (($new_sock, $c_addr) = $sock->accept()) {
    my ($client_port, $c_ip) =
                     sockaddr_in($c_addr);
    my $client_ipnum = inet_ntoa($c_ip);
    my $client_host =
             gethostbyaddr($c_ip, AF_INET);
    print "got a connection from: $client_host",
          " [$client_ipnum]\n";
    while (defined ($buf = <$new_sock>)) {
        print $buf;
    } 
}



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

Date: Fri, 05 Jan 2007 10:37:31 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Unsecured scripts and site hacking?
Message-Id: <g697iw1v610.fsf@dhcp-65-162.kendall.corp.akamai.com>

On  4 Jan 2007, brian.d.foy@gmail.com wrote:

> The only secure computer is the one that's turned off, unplugged,
> encased in concrete, and dropped into the ocean. Even then, I
> wouldn't be surprised to see a CERT advisory.

"Multiple vulnerabilities in 'cement shoes' and 'swimming with fishes'
approaches to security.  Consult your local Mafia Don for up-to-date
patches.  They'll take good care of you."

Ted


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

Date: Fri, 05 Jan 2007 10:30:33 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: using Perl to find string..
Message-Id: <g69bqldv6cm.fsf@dhcp-65-162.kendall.corp.akamai.com>

On  4 Jan 2007, seanjao@yahoo.com wrote:

>> And that's why it's been standard
>> convention to quote material to which you're replying for *decades*.
>
> If so, please let an experienced user, like you to show me how to
> express my appreciation to all of the thoughts posted for this
> topic.

Next time you reply with "thanks" make sure to quote enough so that a
random person could look at your message by itself and understand
what's happening.  Welcome to comp.lang.perl.misc :)

Ted


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

Date: 5 Jan 2007 14:33:42 -0800
From: "Woland99" <woland99@gmail.com>
Subject: Win32::OLE - saving content of just one worksheet in Excel
Message-Id: <1168036422.631782.17470@11g2000cwr.googlegroups.com>

Howdy,

I need to save content of just one workshhet in Excel to tab-delimited
file.
I tried sth like:

$sheet = $wbook->{Worksheets}->{"$sheet_name"};
if($sheet->Activate()){;}
else
{
print STDERR "Could not access Sheet $sheet_name in the file
$fullname_input_file: $!\n";
exit;
}

my $file_type = -4158;     #Constant equivalent for tab delimited file

$wbook->{ActiveSheet}->SaveAs({ FileName => $fullname_output_file,
FileFormat => $file_type })
|| print STDERR "didnt save the sheet $sheet_name of file
$fullname_output_file: $!\n";
$wbook->Close({ FileName => $fullname_output_file});

but SaveAs always fails complaining that $fullname_output_file does not
exists.
Is there sth I am missing?
If I do just:
$wbook->SaveAs({ FileName => $fullname_output_file, FileFormat =>
$file_type })
all works ok except that it save FIRST worksheet in workbook.



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

Date: 5 Jan 2007 16:10:57 -0800
From: "Woland99" <woland99@gmail.com>
Subject: Re: Win32::OLE - saving content of just one worksheet in Excel
Message-Id: <1168042257.840474.211990@42g2000cwt.googlegroups.com>

Well I can do a clumsy workaround - copy active wsheet to
temp workbook and save it - but that is wasteful if you have to
process hundreds of files.
For example:
my $last_row = $sheet->{UsedRange}->Rows()->Count();
my $last_col = $sheet->{UsedRange}->Columns()->Count();
my $upper_left_cell = $sheet->Cells(1,1);
my $lower_right_cell = $sheet->Cells($last_row,$last_col);
my $wbook_temp;
$excel->{SheetsInNewWorkbook} = 1;
$wbook_temp = $excel->Workbooks->Add;
$sheet->Range($upper_left_cell,$lower_right_cell)->Copy();
$wbook_temp->Worksheets(1)->Paste();
$wbook_temp->SaveAs({ FileName => $fullname_output_file, FileFormat =>
$file_type })
|| print STDERR "didnt save the sheet $sheet_name of file
$fullname_output_file: $!\n";
$wbook_temp->Close({ FileName => $fullname_output_file});



Woland99 wrote:
> Howdy,
>
> I need to save content of just one workshhet in Excel to tab-delimited
> file.
> I tried sth like:
>
> $sheet = $wbook->{Worksheets}->{"$sheet_name"};
> if($sheet->Activate()){;}
> else
> {
> print STDERR "Could not access Sheet $sheet_name in the file
> $fullname_input_file: $!\n";
> exit;
> }
>
> my $file_type = -4158;     #Constant equivalent for tab delimited file
>
> $wbook->{ActiveSheet}->SaveAs({ FileName => $fullname_output_file,
> FileFormat => $file_type })
> || print STDERR "didnt save the sheet $sheet_name of file
> $fullname_output_file: $!\n";
> $wbook->Close({ FileName => $fullname_output_file});
>
> but SaveAs always fails complaining that $fullname_output_file does not
> exists.
> Is there sth I am missing?
> If I do just:
> $wbook->SaveAs({ FileName => $fullname_output_file, FileFormat =>
> $file_type })
> all works ok except that it save FIRST worksheet in workbook.



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

Date: Sat, 06 Jan 2007 01:29:50 GMT
From: Brian Helterline <brian.helterline@hp.com>
Subject: Re: Win32::OLE - saving content of just one worksheet in Excel
Message-Id: <459EF49D.1050001@hp.com>

Woland99 wrote:
> Howdy,
> 
> I need to save content of just one workshhet in Excel to tab-delimited
> file.
> I tried sth like:
> 
> $sheet = $wbook->{Worksheets}->{"$sheet_name"};

don't need quotes around "$sheet_name"

> if($sheet->Activate()){;}
$sheet->Select;

> else
> {
> print STDERR "Could not access Sheet $sheet_name in the file
> $fullname_input_file: $!\n";
> exit;
> }
> 
> my $file_type = -4158;     #Constant equivalent for tab delimited file
use Win32::OLE::Const 'Microsoft Excel';
# -4158 => xlCurrentPlatformText

> 
> $wbook->{ActiveSheet}->SaveAs({ FileName => $fullname_output_file,
> FileFormat => $file_type })
FileFormat => xlCurrentPlatformText } )

> || print STDERR "didnt save the sheet $sheet_name of file
> $fullname_output_file: $!\n";
> $wbook->Close({ FileName => $fullname_output_file});

You just saved the file and this will force it to save again.
$wbook->Close( {SaveChange => 0 } );

-- 
brian


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

Date: 5 Jan 2007 17:49:47 -0800
From: "Woland99" <woland99@gmail.com>
Subject: Re: Win32::OLE - saving content of just one worksheet in Excel
Message-Id: <1168048187.082623.154400@i15g2000cwa.googlegroups.com>

Thanks for corrections, Brian.

but the key part:

$sheet->Select;
 $wbook->{ActiveSheet}->SaveAs({ FileName => $fullname_output_file,
FileFormat => xlCurrentPlatformText } )

does not work - I keep getting same error
$! contains string "No such file or directory".

$fullname_output_file:
C:/edata/UserData/backup/features/sdata/scripts/test.txt

JT

Brian Helterline wrote:
> Woland99 wrote:
> > Howdy,
> >
> > I need to save content of just one workshhet in Excel to tab-delimited
> > file.
> > I tried sth like:
> >
> > $sheet = $wbook->{Worksheets}->{"$sheet_name"};
>
> don't need quotes around "$sheet_name"
>
> > if($sheet->Activate()){;}
> $sheet->Select;
>
> > else
> > {
> > print STDERR "Could not access Sheet $sheet_name in the file
> > $fullname_input_file: $!\n";
> > exit;
> > }
> >
> > my $file_type = -4158;     #Constant equivalent for tab delimited file
> use Win32::OLE::Const 'Microsoft Excel';
> # -4158 => xlCurrentPlatformText
>
> >
> > $wbook->{ActiveSheet}->SaveAs({ FileName => $fullname_output_file,
> > FileFormat => $file_type })
> FileFormat => xlCurrentPlatformText } )
>
> > || print STDERR "didnt save the sheet $sheet_name of file
> > $fullname_output_file: $!\n";
> > $wbook->Close({ FileName => $fullname_output_file});
>
> You just saved the file and this will force it to save again.
> $wbook->Close( {SaveChange => 0 } );
> 
> -- 
> brian



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

Date: 5 Jan 2007 07:37:31 -0800
From: "pearly" <michael_perle@yahoo.com>
Subject: Writing a UTF-8 file
Message-Id: <1168011451.696185.106620@v33g2000cwv.googlegroups.com>

Hello everybody,

Does anyone know how I can write UTF-8 files without
a BOM in Perl?

Whether I open files in utf8 mode (2nd parameter of open or
via binmode) I always end up with
- A BOM "FF FE" (UTF-16LE afaik) at the start of the output file;
- Encoding with minimum 2 bytes per character.

I am reading strings from an external resource, so the following
is not 100% representative but has the same effect:

my $string_with_special_chars =3D "Ch=E2teau M=FCller\nGar=E7on";
# String contains entities acirc, uuml and ccedil.
open F, ">:utf8", "test.txt";
print F $string_with_special_chars;

Tried it both on Linux (Perl 5.8.6) and Windows (Perl 5.8.7).

Difference between utf8 and default mode:
The file created without explicit utf8 mode is readable in
Firefox (UTF-8 encoding). My hex editor shows that for all
characters the 2nd byte is 0x00.
The file opened with ">:utf8" shows hex C3 00 A2 00 for the
u umlaut resp. in total 6 bytes more due to the 3 special chars.

Where does the BOM 0xFF 0xFE come from?
Why does Perl add it?
Doesn't Perl write UTF-8 by default?
Why adding the BOM and why 2 or more bytes per character?

Puzzeling since ages (ok, days) on this.

Thank you for any hints.
MP



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

Date: Fri, 05 Jan 2007 16:01:44 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Writing a UTF-8 file
Message-Id: <ZsednaKBnr336wPYnZ2dnUVZ8sfinZ2d@bt.com>

pearly wrote:
> Hello everybody,
> 
> Does anyone know how I can write UTF-8 files without
> a BOM in Perl?
> 

You already posted this question under another name. Why?


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

Date: Fri, 05 Jan 2007 14:49:50 +0000
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Writing UTF-8 file under Windows
Message-Id: <8764blwmsx.fsf@bsb.me.uk>

t_lawetta@yahoo.com writes:

> Happy New Year,
>
> Whatever I try to write a UTF-8 file, I always end up with UTF-16LE
> with the "FF FE" BOM at the beginning and 2 bytes per character.
>
> I am reading strings from an external resource and try to write to
> files.
>
> my $string_with_special_chars = "Château Müller\nGarçon";
> open F, ">:utf8", "test.txt";
> print F $string_with_special_chars;
> close F;
>
> Tried it both on Linux (Perl 5.8.6) and Windows (Perl 5.8.7).

Just a data point.  I can't reproduce your problem using Perl 5.8.7 on
Linux, although I have to either:

(a) tell Perl the source is UTF-8 with "use utf8;", or
(b) re-write the string using the encoding my Perl expects.

You can, of course, just use Unicode code points in strings:
"Ch\x{E2}teau..." and then you don't need to worry...

-- 
Ben.


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

Date: Fri, 05 Jan 2007 15:10:04 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Writing UTF-8 file under Windows
Message-Id: <tsOdnTPeaMPT9wPYnZ2dnUVZ8sqjnZ2d@bt.com>

Ben Bacarisse wrote:
> t_lawetta@yahoo.com writes:
> 
> 
>>Happy New Year,
>>
>>Whatever I try to write a UTF-8 file, I always end up with UTF-16LE
>>with the "FF FE" BOM at the beginning and 2 bytes per character.
>>
>>I am reading strings from an external resource and try to write to
>>files.
>>
>>my $string_with_special_chars = "Château Müller\nGarçon";
>>open F, ">:utf8", "test.txt";
>>print F $string_with_special_chars;
>>close F;
>>
>>Tried it both on Linux (Perl 5.8.6) and Windows (Perl 5.8.7).
> 
> 
> Just a data point.  I can't reproduce your problem using Perl 5.8.7 on
> Linux, although I have to either:
> 
> (a) tell Perl the source is UTF-8 with "use utf8;", or
> (b) re-write the string using the encoding my Perl expects.
> 
> You can, of course, just use Unicode code points in strings:
> "Ch\x{E2}teau..." and then you don't need to worry...
> 

That's what I tried, it's easy to use the wrong encoding
in the source text that contains the string literals. By the time I'd 
cut and pasted the OP's program I'm pretty sure I ended up with my perl 
source file encoded in an obscure codepage.

$ cat utf8.pl
#!/usr/bin/perl
use strict;
use warnings;
#my $string_with_special_chars = "Château Müller\nGarçon";
my $string_with_special_chars =
   "Ch\x{00E2}teau M\x{00FC}ller\nGar\x{00E7}on";
open F, ">:utf8", "test.txt";
print F $string_with_special_chars;
close F;

$ perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi

$ perl utf8.pl

$ hexdump -C test.txt
00000000  43 68 c3 a2 74 65 61 75  20 4d c3 bc 6c 6c 65 72  |Château 
M├╝ller|
00000010  0a 47 61 72 c3 a7 6f 6e                           |.Garçon|
00000018

$ file test.txt
test.txt: UTF-8 Unicode text

Looks good to me, although I can't be bothered to re-read the UTF8 
encoding algorithms to work out manually if the hexdump values agree 
with the `file` command's verdict.


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

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 1
************************************


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