use IPC::Open2; use Symbol; $WTR = gensym(); # get a reference to a typeglob $RDR = gensym(); # and another one $pid = open2($RDR, $WTR, 'bc'); while () { # read commands from user print $WTR $_; # write a command to bc(1) $line = <$RDR>; # read the output of bc(1) print STDOUT "$line"; # send the output to the user }