A typical line needing the comma is
if(defined (defined(&__cplusplus) ? &__cplusplus : 0) && (defined(&__GNUC_PREREQ) ? &__GNUC_PREREQ : 0), (2,8)) {
Notice the comma I inserted between 0) and (2,8)).
Anyways, after fixing that, the following code does what I was looking for. :-)
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; require 'sys/ioctl.ph'; #interface to "bc" calculator my $pid = open3(\*WRITE, \*READ,\*ERROR,"bc"); #if \*ERROR is false, STDERR is sent to STDOUT my($error,$answer)=('',''); while(1){ print "Enter expression for bc, i.e. 2 + 2\n"; chomp(my $query = <STDIN>); #send query to bc print WRITE "$query\n"; #timing delay needed tp let bc output select(undef,undef,undef,.01); #see which filehandles have output from perldoc -q filehandle my $esize = pack("L", 0); ioctl(\*ERROR, FIONREAD(), $esize) or die "Couldn't call ioctl: $!\n"; $esize = unpack("L", $esize); print "esize-> $esize\n"; my $rsize = pack("L", 0); ioctl(\*READ, FIONREAD(), $rsize) or die "Couldn't call ioctl: $!\n"; $rsize = unpack("L", $rsize); print "rsize-> $rsize\n"; #get the output from bc if($esize > 0){sysread(ERROR,$error,$esize); print "Error-> $error\n"} if($rsize > 0){sysread(READ,$answer,$rsize); print "Output->$query = $ +answer\n"} ($error,$answer,$rsize,$esize)=('','',0,0); }
In reply to Re: Re: IPC::Open3 and blocking filehandles
by zentara
in thread IPC::Open3 and blocking filehandles
by zentara
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |