How to pipe input to a src_block as stdin ?

♀尐吖头ヾ 提交于 2019-12-10 14:48:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!