[26746] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8830 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 5 14:05:30 2006

Date: Thu, 5 Jan 2006 11:05:05 -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           Thu, 5 Jan 2006     Volume: 10 Number: 8830

Today's topics:
    Re: calling subroutine via hash <vzeo882n@verizon.net>
    Re: GD - way to preserve PNG transparency? <kisrael@sunfire13.eecs.tufts.edu>
    Re: IO::Pipe and loss of data xhoster@gmail.com
    Re: output of system() call <zentara@highstream.net>
    Re: regex bug? (Anno Siegel)
        Using system Commands In threads <darronm@model.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 05 Jan 2006 14:51:10 GMT
From: "John W. Burns" <vzeo882n@verizon.net>
Subject: Re: calling subroutine via hash
Message-Id: <ynavf.2781$494.1940@trndny07>

Thanks for the help.  Your suggestions work.
JWB




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

Date: Thu, 05 Jan 2006 15:03:17 GMT
From: Kirk Is <kisrael@sunfire13.eecs.tufts.edu>
Subject: Re: GD - way to preserve PNG transparency?
Message-Id: <Vyavf.1434$No6.34489@news.tufts.edu>

Also, let me know if this is the correct newsgroup...
I know technically this is a module inssue, not core Perl, but the modules 
group seems to be kind of dead.  I don't know if there's a graphics 
specific group that might know better?

I guess one thing is, maybe I could have done a better job exporting w/ 
GIMP? In terms of selecting a new unsed color, and doing a background 
layer of that color, and then just picking that color specifically and 
setting it transparent in GD.

But that would mean I'd have to redo 65 or so images, and I'd like to 
avoid that if someone has a better idea...

Thanks!


-- 
QUOTEBLOG: http://kisrael.com   SKEPTIC MORTALITY: http://kisrael.com/mortal
"There are two adults and one child. Majority rules. 
 Live like an animal or die." --James Israel


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

Date: 05 Jan 2006 18:07:09 GMT
From: xhoster@gmail.com
Subject: Re: IO::Pipe and loss of data
Message-Id: <20060105130709.649$mm@newsreader.com>

"Genevieve S." <none@here.com> wrote:
> Hello again,
>
> > How much time do you expect that to take?
> I cannot express this in seconds or anything but as reading from any pipe
> blocks until there is anything to read,

Not if you use nonblocking approaches.  That is painful to program, but
generally quite fast to run.

> > You could try "flock"ing the write handle before each write, but I
> > doubt that will help.

> I do not have a clue how this could work, so I am willing to believe
> xhoster that this does not really work with Linux (which I use). But this
> will work with named pipes - so maybe I will just switch that type to see
> if the error still exists.

Please let us know if it works.

>
> > I think this problem is much more complicated than you
> > think it is.  Look into IO::Select.
> That first sentence is not making an easy day :) I had a look again to
> IO::Select - what I tried to use to find out if my pipe is readable
> (which was quite nonsense, as there is a difference between the shown
> 'open to read' and the searched 'something in to be read').

I don't quite understand what this statement means.

If can_read reports it is readable, then it should be readable.  The
problem is that you need to use read, not readline, to read it, and then do
your own buffering and end-of-message detection.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Thu, 05 Jan 2006 14:28:14 GMT
From: zentara <zentara@highstream.net>
Subject: Re: output of system() call
Message-Id: <vgaqr1tuosfs999vodpgkre4q232m6svde@4ax.com>

On Wed, 4 Jan 2006 10:45:42 -0500, "Madhu Ramachandran"
<madhuram@nortel.com> wrote:

>question.
>
>i am perl newbie. i read that system() call  can be used to invoke other 
>program (shell scripts etc). The return code of the program is returned by 
>system() call and i have to >> by 8 bits.
>
>is there any variable which will contain ouput printed by the program in 
>system() call?
>
>eg:
>system("mytest.sh");
>if mytest.sh has echo "bla" in it. how can i capture the 'bla' value, using 
>the system() call?
>
>currently iam doing this.
>system ("mytest.sh > /tmp/outfile");
># I open this /tmp/outfile and use $line = <outFp>; and get the value.
>
>wondering if there is an easier way to get output.

Here is a super simple example using IPC::Open3. Of course,
you don't need the bash, you can run mytest.sh directly.

There are many more techniques around to enhance your use
of IPC::Open3, google for them.
#!/usr/bin/perl 
use warnings;
use strict;
use IPC::Open3;
$|=1;

#my $pid=open3(\*IN,\*OUT,\*ERR,'/bin/bash');
my $pid=open3(\*IN,\*OUT,0,'/bin/bash');
# set \*ERR to 0 to send STDERR to STDOUT

my $cmd = 'date';
#send cmd to bash
print IN "$cmd\n";   #need the \n with bash

#getresult
my $result = <OUT>;
print $result;

__END__






-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: 5 Jan 2006 14:56:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regex bug?
Message-Id: <dpjc2v$f7k$1@mamenchi.zrz.TU-Berlin.DE>

John W. Krahn <krahnj@telus.net> wrote in comp.lang.perl.misc:
> Eric Niebler wrote:
> > 
> > Consider the following program:
> > 
> >   $str = 'aaA';
> >   $str =~ /(((?:a))?)+/i;
> >   if(defined($2)) { print "$2"; }
> >   else { print "not defined"; }
> > 
> > This prints "not defined," and I think that's right. But if I change the
> > regex to /(((a))?)+/i (that is, if I change the third group from
> > non-capturing to capturing), the program prints "A".
> > 
> > I can't think of a reason why changing group 3 from non-capturing to
> > capturing should have any effect on whether group 2 captures anything.
> > Seems like a regex bug to me. Opinions?
> > 
> > FWIW, I'm running ActiveState perl v5.8.7 815 for Win32.
> 
> When using (((a))?)+ $3 is not optional so it must capture something and since
> it is inside $2 then $2 will also capture the same thing.  When using
> (((?:a))?)+ it is the same as saying ((a)?)+ where the contents of $2 are
> optional.

I don't buy that explanation.  $3 is in the range of a "?", so it
*is* optional. (Actually, the *match* of this part is optional, the
capture is never optional.)  Witness

    use Data::Dumper;

    my $str = 'bbB';
    $str =~ /(((a))?)+/i or die;
    print Dumper [ $1, $2, $3];

which doesn't die.

I think it's a bug.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Thu, 05 Jan 2006 14:14:10 GMT
From: "ukmay" <darronm@model.com>
Subject: Using system Commands In threads
Message-Id: <SQ9vf.75485$a15.27220@newsfe5-win.ntli.net>

Hello,

I'm new to PERL and have just completed a script that does some process 
using an external program. The script is working great but I want to make 
use of multi-threading to run multiple copies of the external program and 
gather the output. I can get the following code to work with the system 
command ;

use strict;
use warnings;
use Env;
use POSIX;
use Thread;

my $thr1 = new Thread \&sub1, "vsim_1133390003.fcdb";
my $thr2 = new Thread \&sub1, "vsim_1133390008.fcdb";
my $thr3 = new Thread \&sub1, "vsim_1133390025.fcdb";

foreach my $thr (threads->list) {
  my @ReturnData = $thr->join;
  print "Thread returned @ReturnData\n";
}

sub sub1 {
  my @InboundParameters = @_;
  my $FileName = $InboundParameters[0];
  print "Processing $FileName\n";
  #my $sys = system "vcover stats $FileName";
  return 1 ;
}

However I need to get hold of the return information from the command that I 
run from system. system() itself doesn't return the stdout so I have to use 
the ' method I believe. However as soon as I change the line above in sub1 
to be

my @value = `vcover stats $FileName `;

The script hangs. Can someone help me with this as I have tried all kinds of 
things and I'm getting nowhere :)

Many Thanks

Darron 




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

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


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