[29645] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 889 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 28 21:09:44 2007

Date: Fri, 28 Sep 2007 18:09:12 -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           Fri, 28 Sep 2007     Volume: 11 Number: 889

Today's topics:
        creating something M$ Excel can read? <mikee@mikee.ath.cx>
    Re: creating something M$ Excel can read? <asolkar@gmail.com>
    Re: creating something M$ Excel can read? <ben@morrow.me.uk>
    Re: creating something M$ Excel can read? (Mark Hobley)
    Re: creating something M$ Excel can read? <mikee@mikee.ath.cx>
    Re: creating something M$ Excel can read? (Gary E. Ansok)
    Re: How to get some specify lines in a block of a file? <allergic-to-spam@no-spam-allowed.org>
        looping questions <lerameur@yahoo.com>
    Re: looping questions <allergic-to-spam@no-spam-allowed.org>
    Re: looping questions (Greg Bacon)
    Re: looping questions xhoster@gmail.com
        Problem installing IO::Compress::Base <joliver@john-oliver.net>
    Re: Problem installing IO::Compress::Base <ben@morrow.me.uk>
    Re: Read attachment <mgjv@tradingpost.com.au>
    Re: SOAP timing out <raherh@gmail.com>
    Re: SOAP timing out <perl4hire@softouch.on.ca>
    Re: Sort and remove duplicates <m@rtij.nl.invlalid>
    Re: string concatentation vs. interpolation: which one  <emschwar@pobox.com>
    Re: Trying to start a perl script as Windows Service <bill@ts1000.us>
    Re: Trying to start a perl script as Windows Service <dn.perl@gmail.com>
        using IPC::Open3 to write to *and* read from a process. <ru@vakuum.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Sep 2007 18:00:09 GMT
From: Mike <mikee@mikee.ath.cx>
Subject: creating something M$ Excel can read?
Message-Id: <46fd4129$0$26430$88260bb3@free.teranews.com>

I want to create a file on linux that is pushed over an apache
connection that excel can open, read, process, etc. This file
is full of monthly project, time sheet type data. I suppose I
could use the Visual Basic for Application, but I'd rather not.
Is there some way to generate a file on linux that contains
formulas, formatting, etc, that can be read by Excel?

Mike

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



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

Date: Fri, 28 Sep 2007 19:19:00 -0000
From:  Mahesh Asolkar <asolkar@gmail.com>
Subject: Re: creating something M$ Excel can read?
Message-Id: <1191007140.586145.295910@d55g2000hsg.googlegroups.com>

On Sep 28, 11:00 am, Mike <mi...@mikee.ath.cx> wrote:
> I want to create a file on linux that is pushed over an apache
> connection that excel can open, read, process, etc. This file
> is full of monthly project, time sheet type data. I suppose I
> could use the Visual Basic for Application, but I'd rather not.
> Is there some way to generate a file on linux that contains
> formulas, formatting, etc, that can be read by Excel?
>

I have used the Spreadsheet::WriteExcel module pretty effective in the
past.

http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm

Spreadsheet::ParseExcel is also useful to read data from MS Excel
spreadsheet.

HTH,
Mahesh.



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

Date: Fri, 28 Sep 2007 20:15:15 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: creating something M$ Excel can read?
Message-Id: <3f00t4-61a.ln1@osiris.mauzo.dyndns.org>


Quoth Mike <mikee@mikee.ath.cx>:
> I want to create a file on linux that is pushed over an apache
> connection that excel can open, read, process, etc. This file
> is full of monthly project, time sheet type data. I suppose I
> could use the Visual Basic for Application, but I'd rather not.
> Is there some way to generate a file on linux that contains
> formulas, formatting, etc, that can be read by Excel?

Spreadsheet::WriteExcel

Ben



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

Date: Fri, 28 Sep 2007 20:08:03 GMT
From: markhobley@hotpop.deletethisbit.com (Mark Hobley)
Subject: Re: creating something M$ Excel can read?
Message-Id: <9c30t4-90d.ln1@neptune.markhobley.yi.org>

Mike <mikee@mikee.ath.cx> wrote:
> Is there some way to generate a file on linux that contains
> formulas, formatting, etc, that can be read by Excel?

Microsoft Excel can read comma separated lists (.csv files). I would create a
test file, and try importing it into Excel.

Mark.

-- 
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/



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

Date: 28 Sep 2007 22:23:17 GMT
From: Mike <mikee@mikee.ath.cx>
Subject: Re: creating something M$ Excel can read?
Message-Id: <46fd7ed5$0$26480$88260bb3@free.teranews.com>

In article <3f00t4-61a.ln1@osiris.mauzo.dyndns.org>, Ben Morrow wrote:
> 
> Quoth Mike <mikee@mikee.ath.cx>:
>> I want to create a file on linux that is pushed over an apache
>> connection that excel can open, read, process, etc. This file
>> is full of monthly project, time sheet type data. I suppose I
>> could use the Visual Basic for Application, but I'd rather not.
>> Is there some way to generate a file on linux that contains
>> formulas, formatting, etc, that can be read by Excel?
> 
> Spreadsheet::WriteExcel
> 
> Ben
> 

I thought of Spreadsheet::WriteExcel before I posted, but didn't
check it out first. I had it in my head that Spreadsheet::WriteExcel
would not work on linux, only on Windows.

Thanks.

Mike

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



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

Date: Sat, 29 Sep 2007 01:01:10 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: creating something M$ Excel can read?
Message-Id: <fdk84l$sd2$1@naig.caltech.edu>

In article <46fd7ed5$0$26480$88260bb3@free.teranews.com>,
Mike  <mikee@mikee.ath.cx> wrote:
>In article <3f00t4-61a.ln1@osiris.mauzo.dyndns.org>, Ben Morrow wrote:
>> 
>> Quoth Mike <mikee@mikee.ath.cx>:
>>> I want to create a file on linux that is pushed over an apache
>>> connection that excel can open, read, process, etc. This file
>>> is full of monthly project, time sheet type data. I suppose I
>>> could use the Visual Basic for Application, but I'd rather not.
>>> Is there some way to generate a file on linux that contains
>>> formulas, formatting, etc, that can be read by Excel?
>> 
>> Spreadsheet::WriteExcel
> 
>I thought of Spreadsheet::WriteExcel before I posted, but didn't
>check it out first. I had it in my head that Spreadsheet::WriteExcel
>would not work on linux, only on Windows.

I use Spreadsheet::WriteExcel on a Solaris system to create spreadsheets
served from an Apache server to be downloaded on Windows clients, and 
it works very well.

Gary


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

Date: Fri, 28 Sep 2007 21:55:17 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: How to get some specify lines in a block of a file?
Message-Id: <slrnffqn0v.1mb.allergic-to-spam@no-spam-allowed.org>

On 2007-09-28, Jan Pluntke <ulmai@gmx.de> wrote:
> dolphin <jdxyw2004@gmail.com> writes:
>
>>    I have a question now,How to get some specify lines in a block of a
>> file?

Sorry, your English is pretty good, but I can't but help correct this:

specify -> specific

>
> [...]
>
>> I just want to get some specify lines in the block of ABC{ }.
>> What should I do?
>
> If I understand your question correctly,
>
>   perldoc -q lines between patterns
>
> might provide an answer.
>
> Regards,
> Jan

To make my post relevant - dolphin pointed to the answer, or info that
can lead to your answer, which is - from the perldoc faq:

Found in /usr/lib/perl5/5.8.6/pod/perlfaq6.pod
       How can I pull out lines between two patterns that are themselves on
       different lines?

       You can use Perl’s somewhat exotic ".." operator (documented in per-
       lop):

           perl -ne ’print if /START/ .. /END/’ file1 file2 ...

       If you wanted text and not lines, you would use

           perl -0777 -ne ’print "$1\n" while /START(.*?)END/gs’ file1 file2 ...

       But if you want nested occurrences of "START" through "END", you’ll run
       up against the problem described in the question in this section on
       matching balanced text.

       Here’s another example of using "..":

           while (<>) {
               $in_header =   1  .. /^$/;
               $in_body   = /^$/ .. eof();
               # now choose between them
           } continue {
               reset if eof();         # fix $.
           }


-- 



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

Date: Fri, 28 Sep 2007 13:07:08 -0700
From:  lerameur <lerameur@yahoo.com>
Subject: looping questions
Message-Id: <1191010028.753764.76290@d55g2000hsg.googlegroups.com>

Hello,

this is not a perl problem (maybe it is). The function does work, but
gave me error . there are 4 files into the traffic directory, the loop
goes into 24 possiblility, copies the four files and gives me 20
errors. I decided to add an IF statement to only copy if the file
exists. what is wrong with my IF loop ?
thanks

Ken



for my $hours ('00'..'23') {

$file23 = glob("$timestamp2$hours*") ;
print  "$timestamp2:   " ,$timestamp2, "\n";
print  "file23: " ,$file23, "\n";
if ($file23 == 1){
system(`cp /input/fttr/traffic/$file23 /input/$Out_directory `);
}

$hours++;
}



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

Date: Fri, 28 Sep 2007 22:38:58 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: looping questions
Message-Id: <slrnffqpis.29h.allergic-to-spam@no-spam-allowed.org>

On 2007-09-28, lerameur <lerameur@yahoo.com> wrote:
> Hello,
>
> this is not a perl problem (maybe it is). The function does work, but
> gave me error . there are 4 files into the traffic directory, the loop
> goes into 24 possiblility, copies the four files and gives me 20
> errors. I decided to add an IF statement to only copy if the file
> exists. what is wrong with my IF loop ?
> thanks

You forgot to report the errors, or a good summary of the errors, in
your post.
>
> Ken
>

Did you 'use strict;', 'use warnings;'?

>
>
> for my $hours ('00'..'23') {
>
> $file23 = glob("$timestamp2$hours*") ;

Odd var name.

> print  "$timestamp2:   " ,$timestamp2, "\n";
> print  "file23: " ,$file23, "\n";
> if ($file23 == 1){

Why are you testing whether $file23 equals 1?  You probably want:
if ($file23){

> system(`cp /input/fttr/traffic/$file23 /input/$Out_directory `);
> }
>
> $hours++;
> }
>

-- 



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

Date: Fri, 28 Sep 2007 20:56:58 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: looping questions
Message-Id: <13fqqkqk4b5ro93@corp.supernews.com>

In article <1191010028.753764.76290@d55g2000hsg.googlegroups.com>,
    lerameur  <lerameur@yahoo.com> wrote:

: for my $hours ('00'..'23') {
:     [...]
:     $hours++;
: }

Your code is doing twice as much work as necessary to compute
the values of $hours:

  1. Your for loop sets up a loop over '00' .. '23'
  2. You increment $hours at the end of each iteration,
     but the value is ignored.

You can remove the line with the increment.

: $file23 = glob("$timestamp2$hours*") ;

What if there's more than one match?

: if ($file23 == 1){
: system(`cp /input/fttr/traffic/$file23 /input/$Out_directory `);
: }

I don't see how the condition could ever be true because your
glob shouldn't match a file whose name is 1.

Perl's system operator wants a command to run, e.g.,

    system("ls -l /etc/motd");

Backticks (``) also want a command. The value of a command
quoted with backticks is the output of running it. For example:

    $ perl -e 'print `echo 1 + 2 | bc` * 4, "\n"'
    12

You usually don't want to combine them as you've done because
that would run one command and then attempt to run its output
a second command, e.g.,

    $ perl -e 'system `echo ls /`'

Consider the following improvements:

    for my $hours ('00' .. '23') {
      my $cmd = join " " => "cp",
                            "/input/fttr/traffic/$timestamp2$hours*",
                            "/input/$Out_directory";

      system $cmd;
    }

You could even condense your code to a single command:

    my $base = "/input/fttr/traffic/$timestamp2";
    system join " " => "cp",
                       map("$base$_*", '00' .. '23'),
                       "/input/$Out_directory";

Hope this helps,
Greg
-- 
Some cause happiness wherever they go; others whenever they go.
    -- Oscar Wilde


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

Date: 28 Sep 2007 21:51:25 GMT
From: xhoster@gmail.com
Subject: Re: looping questions
Message-Id: <20070928175127.859$9F@newsreader.com>

lerameur <lerameur@yahoo.com> wrote:
> Hello,
>
> this is not a perl problem (maybe it is). The function does work, but
> gave me error . there are 4 files into the traffic directory, the loop
> goes into 24 possiblility, copies the four files and gives me 20
> errors. I decided to add an IF statement to only copy if the file
> exists. what is wrong with my IF loop ?
> thanks
>
> Ken
>
> for my $hours ('00'..'23') {
>
> $file23 = glob("$timestamp2$hours*") ;

You don't want to use scalar glob here.  globs are kind of weird,
and it won't notice that it's argument changed until the is done iterating
through all of the files that matched its initial invocation (and has
returned undef once).  Then it will look at its argument again, and start
iterating over that result.  If you know that no more than one file will
match, or you only care about one of the matches in cases where there are
more than one, you could get it by using a list context:

my ($file23) = glob("$timestamp2$hours*") ;

> print  "$timestamp2:   " ,$timestamp2, "\n";
> print  "file23: " ,$file23, "\n";
> if ($file23 == 1){

That is wrong.  It is not clear what exactly is wrong because we don't
what you want it to do.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: 28 Sep 2007 19:02:01 GMT
From: John Oliver <joliver@john-oliver.net>
Subject: Problem installing IO::Compress::Base
Message-Id: <slrnffqjud.2la.joliver@ns.sdsitehosting.net>

cpan[1]> install IO::Compress::Base
CPAN: Storable loaded ok (v2.15)
Going to read /root/.cpan/Metadata
  Database was generated on Fri, 28 Sep 2007 17:36:46 GMT
Running install for module 'IO::Compress::Base'
Running make for P/PM/PMQS/IO-Compress-Base-2.006.tar.gz
CPAN: Digest::SHA loaded ok (v5.45)
CPAN: Compress::Zlib loaded ok (v1.42)
Checksum for
/root/.cpan/sources/authors/id/P/PM/PMQS/IO-Compress-Base-2.006.tar.gz
ok
Scanning cache /root/.cpan/build for sizes
 ............................................................................DONE
IO-Compress-Base-2.006/
IO-Compress-Base-2.006/t/
IO-Compress-Base-2.006/t/compress/
IO-Compress-Base-2.006/t/compress/generic.pl
IO-Compress-Base-2.006/t/compress/zlib-generic.pl
IO-Compress-Base-2.006/t/compress/merge.pl
IO-Compress-Base-2.006/t/compress/oneshot.pl
IO-Compress-Base-2.006/t/compress/anyunc.pl
IO-Compress-Base-2.006/t/compress/newtied.pl
IO-Compress-Base-2.006/t/compress/prime.pl
IO-Compress-Base-2.006/t/compress/tied.pl
IO-Compress-Base-2.006/t/compress/truncate.pl
IO-Compress-Base-2.006/t/compress/multi.pl
IO-Compress-Base-2.006/t/compress/destroy.pl
IO-Compress-Base-2.006/t/compress/CompTestUtils.pm
IO-Compress-Base-2.006/t/compress/any.pl
IO-Compress-Base-2.006/t/000prereq.t
IO-Compress-Base-2.006/t/Test/
IO-Compress-Base-2.006/t/Test/More.pm
IO-Compress-Base-2.006/t/Test/Simple.pm
IO-Compress-Base-2.006/t/Test/Builder.pm
IO-Compress-Base-2.006/t/01misc.t
IO-Compress-Base-2.006/t/99pod.t
IO-Compress-Base-2.006/t/globmapper.t
IO-Compress-Base-2.006/Changes
IO-Compress-Base-2.006/lib/
IO-Compress-Base-2.006/lib/IO/
IO-Compress-Base-2.006/lib/IO/Uncompress/
IO-Compress-Base-2.006/lib/IO/Uncompress/Base.pm
IO-Compress-Base-2.006/lib/IO/Uncompress/AnyUncompress.pm
IO-Compress-Base-2.006/lib/IO/Compress/
IO-Compress-Base-2.006/lib/IO/Compress/Base.pm
IO-Compress-Base-2.006/lib/IO/Compress/Base/
IO-Compress-Base-2.006/lib/IO/Compress/Base/Common.pm
IO-Compress-Base-2.006/lib/File/
IO-Compress-Base-2.006/lib/File/GlobMapper.pm
IO-Compress-Base-2.006/private/
IO-Compress-Base-2.006/private/MakeUtil.pm
IO-Compress-Base-2.006/MANIFEST
IO-Compress-Base-2.006/META.yml
IO-Compress-Base-2.006/pod/
IO-Compress-Base-2.006/pod/FAQ.pod
IO-Compress-Base-2.006/Makefile.PL
IO-Compress-Base-2.006/README
CPAN: File::Temp loaded ok (v0.18)
CPAN: YAML loaded ok (v0.66)

  CPAN.pm: Going to build P/PM/PMQS/IO-Compress-Base-2.006.tar.gz

Up/Downgrade not needed.
Checking if your kit is complete...
Looks good
Writing Makefile for IO::Compress::Base
cp lib/IO/Uncompress/Base.pm blib/lib/IO/Uncompress/Base.pm
cp lib/IO/Uncompress/AnyUncompress.pm
blib/lib/IO/Uncompress/AnyUncompress.pm
cp lib/File/GlobMapper.pm blib/lib/File/GlobMapper.pm
cp lib/IO/Compress/Base.pm blib/lib/IO/Compress/Base.pm
cp lib/IO/Compress/Base/Common.pm blib/lib/IO/Compress/Base/Common.pm
Manifying blib/man3/IO::Uncompress::AnyUncompress.3pm
Manifying blib/man3/IO::Uncompress::Base.3pm
Manifying blib/man3/IO::Compress::Base.3pm
Manifying blib/man3/File::GlobMapper.3pm
  PMQS/IO-Compress-Base-2.006.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/000prereq.....ok
t/01misc........Use of uninitialized value in concatenation (.) or
string at /usr/lib/perl5/5.8.8/Scalar/Util.pm line 30.

#     Failed test (t/01misc.t at line 29)
# You don't have the XS version of Scalar::Util
# Looks like you failed 1 test of 78.
t/01misc........dubious
        Test returned status 1 (wstat 256, 0x100)
DIED. FAILED test 3
        Failed 1/78 tests, 98.72% okay (less 1 skipped test: 76 okay,
97.44%)
t/99pod.........skipped
        all skipped: Test::Pod 1.00 required for testing POD
t/globmapper....ok
Failed Test Stat Wstat Total Fail  List of Failed
-------------------------------------------------------------------------------
t/01misc.t     1   256    78    1  3
1 test and 1 subtest skipped.
Failed 1/4 test scripts. 1/147 subtests failed.
Files=4, Tests=147,  0 wallclock secs ( 0.17 cusr +  0.05 csys =  0.22
CPU)
Failed 1/4 test programs. 1/147 subtests failed.
make: *** [test_dynamic] Error 255
  PMQS/IO-Compress-Base-2.006.tar.gz
  /usr/bin/make test -- NOT OK
//hint// To get more information about failing tests, try:
  reports PMQS/IO-Compress-Base-2.006.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 PMQS/IO-Compress-Base-2.006.tar.gz           : make_test NO


-- 
* John Oliver                              http://www.john-oliver.net/ *


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

Date: Fri, 28 Sep 2007 20:22:00 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Problem installing IO::Compress::Base
Message-Id: <or00t4-61a.ln1@osiris.mauzo.dyndns.org>


Quoth John Oliver <joliver@john-oliver.net>:
<snip>
> #     Failed test (t/01misc.t at line 29)
> # You don't have the XS version of Scalar::Util

Seems fairly self-explanatory to me... you need to (re-)install
Scalar::Util, so you get the XS version.

Arguably IO-Compress-Base ought to depend on Task::Weaken, which is
supposed to fix this problem; I guess Paul is more interested in not
introducing new potential problems.

Ben



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

Date: Sat, 29 Sep 2007 08:08:24 +1000
From: Martien verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Read attachment
Message-Id: <slrnffquqo.kof.mgjv@martien.heliotrope.home>

On Fri, 28 Sep 2007 15:51:22 -0000,
	N@p0 <didlep@hotmail.com> wrote:
> Hi,
>
> Please, I wich read some mails with POP or IMAP protocol and extract
> attachment from these. How can i do this in perl (of course) ?

I'd probably use Net::IMAP (or Net::IMAP::Simple) to get the message,
and MIME::Tools to unpack it. There may be alternative modules that can
be used. Have a look on CPAN, or do a search on your favourite web or
Usenet search engine. Mine's at www.google.com.

Martien
-- 
                        | 
Martien Verbruggen      | Think of the average person. Half of the
                        | people out there are dumber.
                        | 


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

Date: Fri, 28 Sep 2007 18:21:43 +0000
From: rahed <raherh@gmail.com>
Subject: Re: SOAP timing out
Message-Id: <uejgips5k.fsf@gmail.com>

Amer Neely <perl4hire@softouch.on.ca> writes:

> I have a working script that successfully sends data from my home PC
> to a SOAP server in a .NET environment. I run Win2K on this box.
>
> When I upload the script to a Redhat server, it times out, and does
> not submit any data.
>
> Anyone have a clue what might be causing this?

Change a SOAPAction header through an on_action method.

-- 
Radek


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

Date: Fri, 28 Sep 2007 15:34:44 -0400
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Re: SOAP timing out
Message-Id: <2GcLi.590$9F1.243@read1.cgocable.net>

rahed wrote:
> Amer Neely <perl4hire@softouch.on.ca> writes:
> 
>> I have a working script that successfully sends data from my home PC
>> to a SOAP server in a .NET environment. I run Win2K on this box.
>>
>> When I upload the script to a Redhat server, it times out, and does
>> not submit any data.
>>
>> Anyone have a clue what might be causing this?
> 
> Change a SOAPAction header through an on_action method.
> 

Ummm. I'm sorry but can you provide a little more detail for that? I'm 
new to SOAP and .NET, so I need a little more to work with.

-- 
Amer Neely
w: www.webmechanic.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"Others make web sites. We make web sites work!"


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

Date: Fri, 28 Sep 2007 22:54:43 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Sort and remove duplicates
Message-Id: <pan.2007.09.28.20.55.10@rtij.nl.invlalid>

On Fri, 28 Sep 2007 06:10:54 -0700, JimJx wrote:

> Hi everyone,
> 
> Got what should be an easy problem.
> 
> I have a db (MySQL) that I need to sort on the first field  and remove
> dups from.
> 
> For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5 and
> Green,1,2,3,4,5 and Green,2,2,2,2,2
> 
> How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;Red,1,2,3,4,5??
> 
> I know that there is a simple way to do this but my brain is not
> functioning right now.

select field1, min(field2), min(field3) ... from table group by field1;

HTH,
M4


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

Date: 28 Sep 2007 12:57:40 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <877ima62jf.fsf@pobox.com>

Tad McClellan <tadmc@seesig.invalid> writes:
> Here's some more:
> 
>   http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize

I prefer the relatively pithy "Not Yet".

-=Eric


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

Date: Fri, 28 Sep 2007 11:46:19 -0700
From:  Bill H <bill@ts1000.us>
Subject: Re: Trying to start a perl script as Windows Service
Message-Id: <1191005179.659459.324250@g4g2000hsf.googlegroups.com>

On Sep 28, 12:45 pm, "dn.p...@gmail.com" <dn.p...@gmail.com> wrote:
> I want to run a perl script which will continue running on Windows XP
> even after I log off, the way nohup works in Unix. A recommended way
> of doing it is to run the application as Windows Service. Accordingly
> I wrote a test script (myscript.pl), which prints a line every 10
> seconds in an infinite loop :
> Time is 2007-09-27  16:22:25
> Time is 2007-09-27  16:22:35
> Time is 2007-09-27  16:22:45
>
> I created a service for the perl script. When I start the service, it
> stops immediately.
> The message is : The print_tstamp service on local computer started
> and then stopped. Some services stop automatically if they have no
> work to do, for example, the Performance Logs and Alerts service.
>
> Any suggestions, please?

Just a guess - but did it stop because you closed the window, which
means it had no place to print (maybe gets an error?)

Bill H



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

Date: Fri, 28 Sep 2007 22:46:21 -0000
From:  "dn.perl@gmail.com" <dn.perl@gmail.com>
Subject: Re: Trying to start a perl script as Windows Service
Message-Id: <1191019581.354443.327320@o80g2000hse.googlegroups.com>

On Sep 28, 11:46 am, Bill H <b...@ts1000.us> wrote:
> On Sep 28, 12:45 pm, "dn.p...@gmail.com" <dn.p...@gmail.com> wrote:
>
>
>
>
>
> > I want to run a perl script which will continue running on Windows XP
> > even after I log off, the way nohup works in Unix. A recommended way
> > of doing it is to run the application as Windows Service. Accordingly
> > I wrote a test script (myscript.pl), which prints a line every 10
> > seconds in an infinite loop :
> > Time is 2007-09-27  16:22:25
> > Time is 2007-09-27  16:22:35
> > Time is 2007-09-27  16:22:45
>
> > I created a service for the perl script. When I start the service, it
> > stops immediately.
> > The message is : The print_tstamp service on local computer started
> > and then stopped. Some services stop automatically if they have no
> > work to do, for example, the Performance Logs and Alerts service.
>
> > Any suggestions, please?
>
> Just a guess - but did it stop because you closed the window, which
> means it had no place to print (maybe gets an error?)
>
>

Well, I am printing (concatenating) the string to a file.
I tried to run the service with perl, and also with wperl.
But so far nothing has worked. When I log off, the process
terminates.

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




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

Date: Sat, 29 Sep 2007 02:18:30 +0200
From: RU <ru@vakuum.de>
Subject: using IPC::Open3 to write to *and* read from a process...
Message-Id: <fdk5km$n7u$00$1@news.t-online.com>

Hi Folks,

I'm currently working on some cluster scripts which, among other things, 
need to start and stop oracle.  The typical (/bin/sh) nasty cluster 
script does something like:

#!/bin/sh
su -m oracle -c "sqlplus / as sysdba"<<_EOF_
startup
_EOF_

-snip-

I'm trying to provide the same (or better) functionality using more-or-
less pure perl.  I have come up with a subroutine ("run_process()") which 
I will include at the bottom.   I'm using select to determine if there is 
output on STDOUT or STDERR, and if I can write to the process on STDIN 
(if I have input I'd like to send to the process).  The problem is, I'm 
catching SIGCHLD, and when a SIGCHLD is caught, I stop looking for output
from STDOUT and STDERR.  I've tested the subroutine and it seems to work, 
but I'm slightly worried that it might be possible to lose output because 
of the interruption caused by SIGCHLD.  You might wonder why I'm not just 
using Expect.  I'm trying to put something minimal together that solves 
this problem for many cases, and Expect has too much administrative 
overhead for me.  Anyhow, is there a better/more reliable way of ensuring 
I get all the output from the child process?

Also, you may notice that I keep a count of open output filedescriptors 
STDOUT and STDERR, and leave the while-loop when the count reaches zero.  
Unfortunately this does not work, as STDERR doesn't get closed 
(apparently) when the child process terminates, or at least the method I 
used doesn't notice it.  Any comments?

thanks,

Rob Urban

----------------------------snip-----------------------------------------
package ScriptLib;

use FileHandle;
use IPC::Open3;

sub run_command
{
	my ($cmdref, $su_user, $input_ref);

	# parse args
	while($_ = shift) {
		if (/^-cmd/) {
			$cmdref = shift;
		} elsif (/^-su/) {
			$su_user = shift;
		} elsif (/^-input/) {
			$input_ref = shift;
		}
	}

	my $debug = 1;

	my @cmd = @{$cmdref};

	if ($su_user) {
		unshift(@cmd, 'su', '-m', $su_user, '-c');
	}

	my @input = defined($input_ref) ? @{$input_ref} : ();
	my ($read_fh, $write_fh, $err_fh);

	$debug && print "run_command()\n";

	$debug && print "CMD: [", join(' ', @cmd), "]\n";

	$SIG{PIPE} = 'IGNORE';
	$SIG{CHLD} = \&handle_sigchild;

	my $child_exited = 0;
	sub handle_sigchild
	{
		$debug && print "got SIGCHLD!!!\n";
		$child_exited = 1;
	}

	$err_fh = FileHandle->new; # only reader and writer are auto-gen'd
	my $pid = open3($write_fh, $read_fh, $err_fh, @cmd);

	# read output until EOF
	my ($rout, $rin, $wout, $win, $eout, $ein);
	$rin = $ein = '';
	my $nclosed = 0;
	my ($buf, $ret, $out, $err);
	my ($out_open, $err_open) = (1, 1);

	my ($fileno_write, $fileno_err, $fileno_read);

	my $have_input = 0;

	if (@input) {
		$win = '';
		$fileno_write = fileno($write_fh);
		vec($win, $fileno_write, 1) = 1;
		$have_input = 1;
	} else {
		close($write_fh);
	}

	my $want_closed = 0;
	if (defined($read_fh)) {
		$fileno_read = fileno($read_fh);
		vec($rin, $fileno_read, 1) = 1;
		$want_closed++;
	}

	if (defined($err_fh)) {
		$fileno_err = fileno($err_fh);
		vec($ein, $fileno_err, 1) = 1;
		$want_closed++;
	}

	my $input_line;

	$debug && print "  going into read loop...\n";
	while (!$child_exited && ($nclosed < $want_closed)) {
		$debug && print "\n**top of while**,nclosed=[$nclosed]\n";
		if ($have_input && !@input) {
			$debug && print "input exhausted. setting 
win=undef\n";
			$win = undef;
		}

		$debug && print "going into select...\n";
		my $nfound = select($rout=$rin, $wout=$win, $eout=$ein, 
undef);
		$debug && print "after select, nfound=[$nfound]\n";

		if ($nfound) {
			#---------------------------------------------
			# STDOUT
			#---------------------------------------------
			if (vec($rout, $fileno_read, 1)) {
				$debug && print "stdout has something...
\n";
				$ret = sysread($read_fh, $buf, 512);
				$debug && print "read [$ret] bytes\n";
				if ($ret == 0) {
					$nclosed++;
					$debug && print "incrementing 
nclosed\n";
					$out_open = 0;
					$rin = undef;
				}
				$debug && print "  STDOUT: [$buf]\n";
				$out .= $buf;
			}

			#---------------------------------------------
			# STDERR
			#---------------------------------------------
			if (vec($eout, $fileno_err, 1)) {
				$debug && print "stderr has something...
\n";
				$ret = sysread($err_fh, $buf, 512);
				$debug && print "read [$ret] bytes\n";
				if ($ret == 0) {
					$nclosed++;
					$debug && print "incrementing 
nclosed\n";
					$err_open = 0;
				}
				$debug && print "  STDERR: [$buf]\n";
				$err .= $buf;
			}

			#---------------------------------------------
			# STDIN
			#---------------------------------------------
			if (vec($wout, $fileno_write, 1)) {
				$debug && print "stdin is ready for 
input...\n";
				$input_line = shift(@input)."\n";
				$debug && print "INPUT: [$input_line]\n";
				$ret = syswrite($write_fh, $input_line);
				defined($ret) || die "write failed: $!\n";
				$debug && print "wrote [$ret] bytes\n";
			}
		}
	}

	defined($input_ref) && close($write_fh);
	defined($read_fh) && close($read_fh);
	defined($err_fh) && close($err_fh);

	waitpid($pid, 0);
	my $status = $?;
	$debug && print "waitpid returned status [$status]\n";

	return ($status/256, $out, $err);
}

1;


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

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


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