如何将输入作为标准输入通过管道传输到 src_block ? [英] How to pipe input to a src_block as stdin ?

查看:85
本文介绍了如何将输入作为标准输入通过管道传输到 src_block ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下 org-babel 中的 perl 片段,它使用 .

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 ?

说:

#+begin_src text :name test-input
  12.5
#+end_src

推荐答案

您可以将 $rad#+results 块中直接传递给 perl 脚本:参见 将参数传递给手册中的代码块.

You can pass $rad directly to the perl script from a #+results block : see passing arguments to code blocks in the manual.

那会给

#+begin_src perl :results output :var rad=test-input

用作输入

#+results: test-input
:  12.5

这篇关于如何将输入作为标准输入通过管道传输到 src_block ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆