[31676] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2939 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 10 14:09:27 2010

Date: Mon, 10 May 2010 11:09:07 -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           Mon, 10 May 2010     Volume: 11 Number: 2939

Today's topics:
        can't read from STDIN after system call <lndresnick@gmail.com>
    Re: can't read from STDIN after system call <lndresnick@gmail.com>
    Re: can't read from STDIN after system call <ben@morrow.me.uk>
    Re: can't read from STDIN after system call <lndresnick@gmail.com>
    Re: find/copy most recent version of file? <geoff@invalid.invalid>
    Re: find/copy most recent version of file? <uri@StemSystems.com>
    Re: find/copy most recent version of file? <geoff@invalid.invalid>
        how to add rows beyond 65535 in excel using Perl? <balaji.draj@gmail.com>
    Re: how to add rows beyond 65535 in excel using Perl? <tadmc@seesig.invalid>
    Re: how to add rows beyond 65535 in excel using Perl? <rk_dn@yahoo.de>
        will there be a Strawberry Perl 6 / Rakudo Star ? <dilbert1999@gmail.com>
    Re: will there be a Strawberry Perl 6 / Rakudo Star ? <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 10 May 2010 07:41:29 -0700 (PDT)
From: David Resnick <lndresnick@gmail.com>
Subject: can't read from STDIN after system call
Message-Id: <30d26796-68bb-448b-a2c9-cff3e849834e@b18g2000yqb.googlegroups.com>

I've been poking at a script that loses the ability to ready from
<STDIN> after doing a system() call.

I located this
http://perldoc.perl.org/perlfaq8.html#Why-can%27t-my-script-read-from-STDIN-after-I-gave-it-EOF-%28^D-on-Unix,-^Z-on-MS-DOS%29?
which seemed to be the obvious answer to my questions.

But after doing this:
  STDIN->clearerr();

or this:

seek STDIN, 0, SEEK_SET

or this
(at program beginning)
my $stdinBegin = tell(STDIN);

Before trying to read STDIN
    seek(STDIN, $stdinBegin, 0);

or this
    seek(STDIN, 1, 0);
    seek(STDIN, 0, 0);


I still find I eternally get undef from <STDIN> after calling this
system command.  The system command runs sipp, which does nothing
special as far as I can see.  Why would invoking any system command
mess up the parent processes STDIN file handle?

Any suggestions appreciated...


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

Date: Mon, 10 May 2010 08:06:13 -0700 (PDT)
From: David Resnick <lndresnick@gmail.com>
Subject: Re: can't read from STDIN after system call
Message-Id: <b8c8be74-dd00-46eb-9736-b36ffb946dfb@e1g2000yqe.googlegroups.com>

On May 10, 10:41=A0am, David Resnick <lndresn...@gmail.com> wrote:
> I've been poking at a script that loses the ability to ready from
> <STDIN> after doing a system() call.
>
> I located thishttp://perldoc.perl.org/perlfaq8.html#Why-can%27t-my-script=
-read-from...D-on-Unix,-^Z-on-MS-DOS%29?
> which seemed to be the obvious answer to my questions.
>
> But after doing this:
> =A0 STDIN->clearerr();
>
> or this:
>
> seek STDIN, 0, SEEK_SET
>
> or this
> (at program beginning)
> my $stdinBegin =3D tell(STDIN);
>
> Before trying to read STDIN
> =A0 =A0 seek(STDIN, $stdinBegin, 0);
>
> or this
> =A0 =A0 seek(STDIN, 1, 0);
> =A0 =A0 seek(STDIN, 0, 0);
>
> I still find I eternally get undef from <STDIN> after calling this
> system command. =A0The system command runs sipp, which does nothing
> special as far as I can see. =A0Why would invoking any system command
> mess up the parent processes STDIN file handle?
>
> Any suggestions appreciated...

Very interestingly, I figured out that if I close stdin on the system
command (with 0<&-) it works.  Any comments on what I was doing wrong
above or why this works welcom though!


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

Date: Mon, 10 May 2010 17:56:09 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: can't read from STDIN after system call
Message-Id: <9eqlb7-k3.ln1@osiris.mauzo.dyndns.org>


Quoth David Resnick <lndresnick@gmail.com>:
> I've been poking at a script that loses the ability to ready from
> <STDIN> after doing a system() call.

Please post your code, and also your OS and version of perl. Something
like

    perl -E'system "cat"; say scalar <STDIN>;'

works just fine for me here. (The first ^D sends EOF to cat, and any
subsequent lines are happily read by perl.)

> I located this
> http://perldoc.perl.org/perlfaq8.html#Why-can%27t-my-script-read-from-STDIN-after-I-gave-it-EOF-%28^D-on-Unix,-^Z-on-MS-DOS%29?
> which seemed to be the obvious answer to my questions.
> 
> But after doing this:
>   STDIN->clearerr();
> 
> or this:
> 
> seek STDIN, 0, SEEK_SET

Nothing involving seek will work on STDIN if STDIN is connected to a
terminal.

> I still find I eternally get undef from <STDIN> after calling this
> system command.  The system command runs sipp, which does nothing
> special as far as I can see.  Why would invoking any system command
> mess up the parent processes STDIN file handle?

Is it *any* command? What happens if you replace the command with
something innocuous like 'sleep 1'?

Ben



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

Date: Mon, 10 May 2010 10:30:50 -0700 (PDT)
From: David Resnick <lndresnick@gmail.com>
Subject: Re: can't read from STDIN after system call
Message-Id: <81f76ee0-a44c-498b-ae5c-53bb3cefeee9@q32g2000yqb.googlegroups.com>

On May 10, 12:56=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth David Resnick <lndresn...@gmail.com>:
>
> > I've been poking at a script that loses the ability to ready from
> > <STDIN> after doing a system() call.
>
> Please post your code, and also your OS and version of perl. Something
> like
>
> =A0 =A0 perl -E'system "cat"; say scalar <STDIN>;'
>
> works just fine for me here. (The first ^D sends EOF to cat, and any
> subsequent lines are happily read by perl.)
>
> > I located this
> >http://perldoc.perl.org/perlfaq8.html#Why-can%27t-my-script-read-from...=
D-on-Unix,-^Z-on-MS-DOS%29?
> > which seemed to be the obvious answer to my questions.
>
> > But after doing this:
> > =A0 STDIN->clearerr();
>
> > or this:
>
> > seek STDIN, 0, SEEK_SET
>
> Nothing involving seek will work on STDIN if STDIN is connected to a
> terminal.
>
> > I still find I eternally get undef from <STDIN> after calling this
> > system command. =A0The system command runs sipp, which does nothing
> > special as far as I can see. =A0Why would invoking any system command
> > mess up the parent processes STDIN file handle?
>
> Is it *any* command? What happens if you replace the command with
> something innocuous like 'sleep 1'?
>
> Ben

As I mentioned in the follow up, closing stdin on the system command
fixed it.

It does not apply to any command, I discovered that early on.  Once I
saw that the "system" command is what seemed to mess up my STDIN, I
tried the "date" run via system, didn't cause the issue.

The relevant part of the code is here.  Note sipp is an open source
tool to handle SIP traffic.  When run normally it does look for input
in STDIN.

        getline("hit return when ready to execute test $testName\n");

        my $sippCommand =3D "$vobBase/thparty3/sipp/sipp -sf " .
            "$sippFile $remoteIpAddress -trace_msg -m 1 -l 1 -key
testname $testName -key testdir $outputDirRoot/$testName" .
            " > /dev/null 2> /dev/null 0<&-";

        my $sippReturnValue =3D mysystem("$sippCommand");

sub mysystem
{
    my $cmd =3D $_[0];
    my $result =3D 0;
    debug("issuing command '$cmd'\n");

    if (($result =3D system("$cmd")) !=3D 0) {
        warn "command '$cmd' failed";
    }

    return $result;
}

sub debug
{
    if ($debug !=3D 0) {
	print STDERR "@_";
    }

}

sub getline()
{
    my $prompt =3D "@_[0]";
    print $prompt;
    my $line =3D <STDIN>;
    chomp($line);
    return $line;
}

********************

If I don't do the 0<&- in the system call, all future calls to <STDIN>
return eof. But that seems to fix my problem, so I'm now merely just
curious as to why this happens.  I'm still mystified as to why, as I
thought that system would create an independent process that couldn't
alter its parents file descriptor state in any way.

My perl version is: perl, v5.8.8 built for i386-linux-thread-multi

Thanks,
-David


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

Date: Sun, 09 May 2010 23:43:53 +0100
From: Geoff <geoff@invalid.invalid>
Subject: Re: find/copy most recent version of file?
Message-Id: <2ieeu5hb9t0ln00f1ddu5u4nlle8p6g8hq@4ax.com>

On Sun, 09 May 2010 13:28:59 -0400, "Uri Guttman"
<uri@StemSystems.com> wrote:

>  PJH> He wants to find the newest instance and copy that to a target
>  PJH> directory, so if the target directory is named /target/, baz.text will
>  PJH> always be copied to /target/baz.text, regardless where it was found.
>  PJH> No mkpath necessary.
>
>if you could find a logical statement from the OP which claims that
>goal, more power to you! :)

uri

How about my first posting?

> I have a series of files called c1_1.mp4 to c1_120.mp4 which are
> spread over several folders.

> I would like to be able to copy the most recent version of each file
> to new folder.

Is that not clear?

Cheers

Geoff


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

Date: Sun, 09 May 2010 18:55:10 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: find/copy most recent version of file?
Message-Id: <87ocgoit2p.fsf@quad.sysarch.com>

>>>>> "G" == Geoff  <geoff@invalid.invalid> writes:

  G> On Sun, 09 May 2010 13:28:59 -0400, "Uri Guttman"
  G> <uri@StemSystems.com> wrote:

  PJH> He wants to find the newest instance and copy that to a target
  PJH> directory, so if the target directory is named /target/, baz.text will
  PJH> always be copied to /target/baz.text, regardless where it was found.
  PJH> No mkpath necessary.
  >> 
  >> if you could find a logical statement from the OP which claims that
  >> goal, more power to you! :)

  G> uri

  G> How about my first posting?

  >> I have a series of files called c1_1.mp4 to c1_120.mp4 which are
  >> spread over several folders.

  >> I would like to be able to copy the most recent version of each file
  >> to new folder.

  G> Is that not clear?

nope. not by a long shot. it doesn't say anything about paths which has
been a part of this thread. a bulletproof requirements and spec is a lot
harder than you realize. it is effectly defining the results you want
with all possible data issues taken into consideration. what if a newer
version by date is actually an empty file? there are so many little nits
to deal with in even the seemingly smallest problems. this is called
analysis and why early programming jobs were called data analysts. i
wish that title was in use again as it is one of the most important and
ignore part of programming jobs.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Mon, 10 May 2010 07:01:16 +0100
From: Geoff <geoff@invalid.invalid>
Subject: Re: find/copy most recent version of file?
Message-Id: <d38fu5duuv6n1ab5ohcmmb2dce9lhbqpc5@4ax.com>

On Sun, 09 May 2010 18:55:10 -0400, "Uri Guttman"
<uri@StemSystems.com> wrote:

>>>>>> "G" == Geoff  <geoff@invalid.invalid> writes:
>
>  G> On Sun, 09 May 2010 13:28:59 -0400, "Uri Guttman"
>  G> <uri@StemSystems.com> wrote:
>
>  PJH> He wants to find the newest instance and copy that to a target
>  PJH> directory, so if the target directory is named /target/, baz.text will
>  PJH> always be copied to /target/baz.text, regardless where it was found.
>  PJH> No mkpath necessary.
>  >> 
>  >> if you could find a logical statement from the OP which claims that
>  >> goal, more power to you! :)
>
>  G> uri
>
>  G> How about my first posting?
>
>  >> I have a series of files called c1_1.mp4 to c1_120.mp4 which are
>  >> spread over several folders.
>
>  >> I would like to be able to copy the most recent version of each file
>  >> to new folder.
>
>  G> Is that not clear?
>
>nope. not by a long shot. it doesn't say anything about paths which has
>been a part of this thread. a bulletproof requirements and spec is a lot
>harder than you realize. it is effectly defining the results you want
>with all possible data issues taken into consideration. what if a newer
>version by date is actually an empty file? there are so many little nits
>to deal with in even the seemingly smallest problems. this is called
>analysis and why early programming jobs were called data analysts. i
>wish that title was in use again as it is one of the most important and
>ignore part of programming jobs.

OK!

Thanks

Geoff


>
>uri


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

Date: Mon, 10 May 2010 02:54:20 -0700 (PDT)
From: IJALAB <balaji.draj@gmail.com>
Subject: how to add rows beyond 65535 in excel using Perl?
Message-Id: <79359ff8-fdaa-4131-b1cf-583a853630ba@g39g2000pri.googlegroups.com>

Hi,

I need to process huge data from text and output to excel file.
Whenever the output row count hits more than 65535, i get an
exception., i had been splitting my input files and handling it, but
it is cumbersome..how do i handle automatically whenver row count is
more than 65535, my excel setup is called as follows:
sub setup_excel()
{
    $Win32::OLE::Warn = 3;                                # die on
errors...
    # get already active Excel application or open new
    $Excel = Win32::OLE->GetActiveObject('Excel.Application')
    || Win32::OLE->new('Excel.Application', 'Quit');
    $Excel->{DisplayAlerts}=0;
    if (-e "$ReportFile")
    {
        # open Excel file
        $Excel->{Visible} = 0;
        $workbook = $Excel->Workbooks->Open("$ReportFile");
        $worksheet = $workbook->Worksheets(1);
    }
    else
    {
        $Excel->{Visible} = 0;
        $Excel->{SheetsInNewWorkBook} = 2;
        $workbook = $Excel->Workbooks->Add();
        $worksheet = $workbook->Worksheets(1);
        $worksheet->{Name} = "results";
    }

     $worksheet->Range("A:J")->{HorizontalAlignment} = xlCenter;
     with($worksheet->Columns(1), ColumnWidth => 12);
     with($worksheet->Columns(2), ColumnWidth => 15);
     with($worksheet->Columns(3), ColumnWidth => 12);
     with($worksheet->Columns(4), ColumnWidth => 17);
     with($worksheet->Columns(5), ColumnWidth => 17);
     with($worksheet->Columns(6), ColumnWidth => 17);
     with($worksheet->Columns(7), ColumnWidth => 17);
     with($worksheet->Columns(8), ColumnWidth => 12);
     with($worksheet->Columns(9), ColumnWidth => 12);
}


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

Date: Mon, 10 May 2010 07:20:38 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: how to add rows beyond 65535 in excel using Perl?
Message-Id: <slrnhufu77.ond.tadmc@tadbox.sbcglobal.net>

IJALAB <balaji.draj@gmail.com> wrote:

> Subject: how to add rows beyond 65535 in excel using Perl?


That limit is built-in to Excel, nothing you can do about it other
than upgrade to a newer version of Excel.

    http://office.microsoft.com/en-us/excel/ha101375451033.aspx


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


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

Date: Mon, 10 May 2010 14:22:25 +0200
From: Rafael Koeppen <rk_dn@yahoo.de>
Subject: Re: how to add rows beyond 65535 in excel using Perl?
Message-Id: <hs8tpf$okv$03$1@news.t-online.com>

AFAIK this is a limit concerning the number of rows per file
(*not* per sheet) for Excel versions 2003 and before.
Try Excel 2007, it should support up to 1M rows ...

BR Rafael

IJALAB schrieb:
> Hi,
> 
> I need to process huge data from text and output to excel file.
> Whenever the output row count hits more than 65535, i get an
> exception., i had been splitting my input files and handling it, but
> it is cumbersome..how do i handle automatically whenver row count is
> more than 65535, my excel setup is called as follows:
> sub setup_excel()
> {
>     $Win32::OLE::Warn = 3;                                # die on
> errors...
>     # get already active Excel application or open new
>     $Excel = Win32::OLE->GetActiveObject('Excel.Application')
>     || Win32::OLE->new('Excel.Application', 'Quit');
>     $Excel->{DisplayAlerts}=0;
>     if (-e "$ReportFile")
>     {
>         # open Excel file
>         $Excel->{Visible} = 0;
>         $workbook = $Excel->Workbooks->Open("$ReportFile");
>         $worksheet = $workbook->Worksheets(1);
>     }
>     else
>     {
>         $Excel->{Visible} = 0;
>         $Excel->{SheetsInNewWorkBook} = 2;
>         $workbook = $Excel->Workbooks->Add();
>         $worksheet = $workbook->Worksheets(1);
>         $worksheet->{Name} = "results";
>     }
> 
>      $worksheet->Range("A:J")->{HorizontalAlignment} = xlCenter;
>      with($worksheet->Columns(1), ColumnWidth => 12);
>      with($worksheet->Columns(2), ColumnWidth => 15);
>      with($worksheet->Columns(3), ColumnWidth => 12);
>      with($worksheet->Columns(4), ColumnWidth => 17);
>      with($worksheet->Columns(5), ColumnWidth => 17);
>      with($worksheet->Columns(6), ColumnWidth => 17);
>      with($worksheet->Columns(7), ColumnWidth => 17);
>      with($worksheet->Columns(8), ColumnWidth => 12);
>      with($worksheet->Columns(9), ColumnWidth => 12);
> }


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

Date: Mon, 10 May 2010 09:29:22 -0700 (PDT)
From: Dilbert <dilbert1999@gmail.com>
Subject: will there be a Strawberry Perl 6 / Rakudo Star ?
Message-Id: <0690e446-cd0b-4a07-8d6e-5b7751ecbc29@d39g2000yqa.googlegroups.com>

I am a Strawberry Perl 5.12 user on Windows and I was reading
http://rakudo.org/node/69

>> Announce: Rakudo Perl 6 development
>> release #28 ("Moscow")
>> [...]
>> This is not the "Rakudo Star" release
>> announced for Q2 2010 --
>> we expect that to be shipped in June.
>> [...]

 ...and I was thinking: suppose Rakudo Star will be shipped in June,
are there any efforts being made by the good people who gave us
Strawberry Perl 5.8, 5.10 and 5.12 to give us also Strawberry Perl 6 /
Rakudo Star ?


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

Date: Mon, 10 May 2010 17:59:55 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: will there be a Strawberry Perl 6 / Rakudo Star ?
Message-Id: <blqlb7-k3.ln1@osiris.mauzo.dyndns.org>


Quoth Dilbert <dilbert1999@gmail.com>:
> I am a Strawberry Perl 5.12 user on Windows and I was reading
> http://rakudo.org/node/69
> 
> >> Announce: Rakudo Perl 6 development
> >> release #28 ("Moscow")
> >> [...]
> >> This is not the "Rakudo Star" release
> >> announced for Q2 2010 --
> >> we expect that to be shipped in June.
> >> [...]
> 
> ...and I was thinking: suppose Rakudo Star will be shipped in June,
> are there any efforts being made by the good people who gave us
> Strawberry Perl 5.8, 5.10 and 5.12 to give us also Strawberry Perl 6 /
> Rakudo Star ?

The last I heard about this was http://use.perl.org/~Alias/journal/38200
 . That's from Jan 09, though, so some progress may have been made since
then.

Ben



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 2939
***************************************


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