问题
Consider the following snippet of perl in org-babel, which uses <STDIN>
.
** Ans 2
#+begin_src perl :results output
use Math::Trig;
$rad = <STDIN>;
$circumference = 2*pi*$rad;
print "Circumference of circle is $circumference";
#+end_src
Is it possible to pipe the input to this block from another block ?
Say :
#+begin_src text :name test-input
12.5
#+end_src
回答1:
You can pass $rad
directly to the perl script from a #+results
block : see passing arguments to code blocks in the manual.
That would give
#+begin_src perl :results output :var rad=test-input
Using as input
#+results: test-input
: 12.5
来源:https://stackoverflow.com/questions/12129038/how-to-pipe-input-to-a-src-block-as-stdin