在Unix中,我们可以将多个命令放在一行中,如下所示:
$ date ; ls -l ; date
Run Code Online (Sandbox Code Playgroud)
我在Windows中尝试过类似的东西:
> echo %TIME% ; dir ; echo %TIME
Run Code Online (Sandbox Code Playgroud)
但它打印时间并且不执行命令dir.
我怎样才能做到这一点?
我想从文件中读取和处理输入集,然后将其打印出来.我需要使用3个密钥来存储数据.假设有3个键k1, k2, k3
以下哪项将提供更好的性能
$hash{k1}->{k2}->{k3} = $val;
Run Code Online (Sandbox Code Playgroud)
要么
$hash{"k1,k2,k3"} = $val;
Run Code Online (Sandbox Code Playgroud)
对于我之前的问题,我得到的答案是所有perl哈希键都被视为字符串.
我编写了这个示例代码来检查perl哈希中的整数或字符串索引是否更好.
use Time::Local;
use Time::HiRes qw/gettimeofday/;
my %string_hash;
my %int_hash;
$i_count = 100;
$j_count = 100;
$k_count = 1000;
foreach $i (0..$i_count)
{
foreach $i (0..$j_count)
{
foreach $k (0..$k_count)
{
$i += 0;$j += 0;$k += 0;
$int_hash{$i}->{$j}->{$k} = 1;
$string_hash{"$i"}->{"$j"}->{"$k"} = 1;
}
}
}
my $profile = gettimeofday();
print "String hash start:$profile\n";
foreach $i (keys %string_hash)
{
foreach $j(keys %{ $string_hash{$i} })
{
foreach $k(keys %{ $string_hash{$i}{$j} })
{
$i += 0;$j += 0;$k += 0;
$val …Run Code Online (Sandbox Code Playgroud)