xhudik has asked for the wisdom of the Perl Monks concerning the following question:
I'm experiencing a problem with IPC::Run pump function. Well, when I wrote the code as non object-oriented - everything works well. But if I rewrite it into modulino(OOP), pump function get stuck. First, I thought some kind of mistype, but I controlled it many times and everything looks pretty much the same ...
Do you know why I'm getting:
Instead of finishing pumping function and moving forward?... ;;;;;;6 IPC::Run 0001 [#1(9804)]: ** pumping
thanks, Tomas
Program code: (put it into file.pm and run it as: perl file.pm - it will automatically run the run function.
package pak; __PACKAGE__->run(@ARGV) unless caller(); use IPC::Run qw(start pump finish timeout); sub run { ref(my $class= shift) and die "Class name needed"; $|++; my $tok_program = "/bin/./cat"; my @tok_param=(); my $pokus = $class->new($tok_program,@tok_param); $pokus->{tok_in}="hallo\n"; do{ print "zz::$pokus->{tok_in};;$pokus-> {tok_out};;$pokus->{tok_err +};;".length($pokus->{tok_in})."\n"; $pokus->{tok}->pump; print "kk\n"; } while $pokus->{tok_out} !~ /\n\z/; #$r }#sub run sub new{ ref(my $class= shift) and die "Class name needed"; my $tok_program = shift; my @tok_param = @_; my ( $TOK_IN, $TOK_OUT, $TOK_ERR, $TOK ); $TOK = start [ $tok_program, @tok_param ], '<', \$TOK_IN, '1>pty>', +\$TOK_OUT, '2>', \$TOK_ERR, debug => 2 or die "Can't exec program: $?;\n"; my $self = {tok => $TOK, tok_in => $TOK_IN, tok_out => $TOK_OUT, tok +_err => $TOK_ERR, tok_program => $tok_program}; bless $self,$class; return $self; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IPC::pump in object oriented programming
by Eliya (Vicar) on Jan 12, 2012 at 17:14 UTC | |
by xhudik (Initiate) on Jan 13, 2012 at 13:25 UTC |