【发布时间】:2014-10-21 18:01:18
【问题描述】:
我正在尝试创建这个 Perl 程序:
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, "<", "test.txt")
or die "cannot open < file name: $!";
while (my $line = <$fh>) {
print $line;
}
close($fh);
我创建了这个组织文件:
#+BABEL: :cache yes :tangle yes :noweb yes
#+NAME: top_block
#+begin_src perl :tangle test.pl
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, "<", "test.txt")
or die "cannot open < file name: $!";
<<output all the lines from file>>
close($fh);
#+end_src
#+NAME: output all the lines from file
#+begin_src perl :tangle test.pl
while (my $line = <$fh>) {
print $line;
}
#+end_src
但它创造了这个:
empty line here
#!/usr/bin/perl
use strict;
use warnings;
open(my $fh, "<", "test.txt")
or die "cannot open < file name: $!";
<<output all the lines from file>>
close($fh);
while (my $line = <$fh>) {
print $line;
}
问题:
- 文件顶部有一个空行。
- Noweb 块没有展开,而是放在文件底部。
- 没看懂,怎么把输出文件名写在最上面一次?目前,我必须为每个块重写它:
:tangle test.pl。
【问题讨论】:
标签: emacs org-mode literate-programming noweb