Dem*_*eep 0 string perl hash dereference
如何打印$ stopwords?它似乎是一个字符串($)但是当我打印它时,我得到:"HASH(0x8B694)",每次运行时内存地址都会改变.
我正在使用Lingua :: StopWords,我只想打印它正在使用的停用词,所以我肯定知道那里有什么停用词.我想打印这两个文件.
我是否需要尊重$ stopwords?
这是代码:
use Lingua::StopWords qw( getStopWords );
open(TEST, ">results_stopwords.txt") or die("Unable to open requested file.");
my $stopwords = getStopWords('en');
print $stopwords;
Run Code Online (Sandbox Code Playgroud)
我试过了:
my @temp = $stopwords;
print "@temp";
Run Code Online (Sandbox Code Playgroud)
但这不起作用.救命!
最后一点:我知道有一个关于Lingua :: StopWords的停用词列表,但我正在使用(en),我只是想绝对确定我正在使用的停止词,所以这就是为什么我要打印它理想情况下,我想将它打印到文件部分,我应该已经知道该怎么做.
$不是指字符串.它表示标量,可以是字符串,数字或引用.
$stopwords是一个哈希引用.要将它用作哈希,您可以使用%$stopwords.
使用Data::Dumper作为一个快速的方法来打印一个哈希(按引用传递)的内容:
use Data::Dumper;
...
print Dumper($stopwords);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
227 次 |
| 最近记录: |