my %hash = ( 'hi' => ('hello' => 'all'), 'bye' => ('later' => 'gone') ) print $hash{'hi'}; 为什么结果是hello, 而不是显示整个子hash: helloall 呢?
hash Functions A comprehensive collection of hash functions, a hash visualiser and some test results [see Mckenzie et al. Selecting a hashing Algorithm, SP&E 20(2):209-224, Feb 1990] will be available someday. If you just want to have a good hash function, and cannot wait, djb2 is one of the best string hash functions i know. it has excellent distribution and speed on many different sets of keys ...
2.1 PHP中出现的字符串hash函数 static unsigned long hashpjw(char *arKey, unsigned int nKeyLength) { unsigned long h = 0, g; char *arEnd=arKey+nKeyLength; while (arKey < arEnd) { h = (h << 4) + *arKey++; if ((g = (h & 0xF0000000))) { h = h ^ (g >> 24); h = h ^ g; } } return h; } 里面 又是 << 又是 >> ^ 要怎么才能理解? 要是自己写个hash算法 , 怎么考虑要用 << >> ^ ??
my %hash=("a"=>1,"b"=>2,"c"=>3); my $count=%hash; print $count."\n"; 总是显示0, 用@array=%hash 数组里也没东西。 这样对hash赋值有问题吗?
请教一个问题,我创建的一个hash变量,里面即有标量,又有数组,还有hash的hash.请问这个hash变量我要怎么保存,以方便下次调用? 如下: my @test_array = (1..8); my %test_hah = { 'T1'=>'test1', 'T2'=>\@test_array, 'S8'=> { ' T5'=>'test', } ...
不好意思,学perl的时间不多 所有代码: #! /usr/bin/perl -w use PerlIO::gzip; #use strict; #use diagnostics; my $datcounttime=`/bin/sh datcounttime.sh`; chomp($datcounttime); my %Tmphash; my $POPDir="/home/temp/pop1,/home/temp/pop2,/home/temp/pop3,/home/temp/pop4"; my @logDirNames = split /,/, $POPDir; my $abc="abc=101,abc=103,abc=105,abc=107"; my @abcNames=split /,/, $abc; my $counttime="co...
代码如下: sub func() { my %hash = ( aaa => 111, bbb => 222, ccc => 333 ); return \%hash; } my $ref_hash = func(); foreach ( my ($key,$value) = each %{$ref_hash} ) { print $key," => ",$value,"\n"; } 结果是: bbb => 222 bbb => 222 我预想的结果应该是: aaa => 111 bbb => 222 ccc => 333 [ 本帖最后由 qfmeal 于 2009-5-21 17:36 编辑 ]