#tf.pl
#!/usr/local/bin/perl
use Util;
$file = shift;
$text = `cat $file`;
my @words = split_words ($text);
my @words = lc_words (@words);
my %count = count_hash(@words);
while (my ($w, $c) = each %count) {
print "$w\t$c\n";
$df{$w} = 1;
}
我在网站上看到了这段代码。在3号线$文件中给出,将已与命令行参数(纠正我,如果我错了,我是一个Perl的新秀)perl中的字符串中的cat命令在引号中做了什么?
第4行中看到你所提供的文件的名称:
$text = `cat $file`;
我想知道这条线究竟做了什么?我知道cat filename
在向您显示终端中的文件内容(再次,纠正我,如果错了,Linux新手也)
我问过这个关于IRC和有人说这是一个坏的方式做事,但我真的想要知道这是做什么比知道更好的替代它
请注意,shebang行'#!/ usr/local/bin/perl'除非它是该文件的第一行,否则不行。 –