my $size=scalar keys%hash_ref; 37 print STDERR "top-level hash_ref $size\n"; 38 foreach my $key (keys %hash_ref) 39 { 40 $size=scalar keys%{$hash_ref{$key}}; 41 print STDERR "second-level hash_ref $size\n"; 42 43 } 44 foreach my $key (keys %hash_ref) 45 { 46 foreach my $subkey (keys %{$hash_ref{$key}}) 47 { 48 print STDERR "$key\t$subkey\n"; 49 50 } 51 }
字符串数组相关:
use strict; use warnings; my $asc=ord("我"); my $val=$asc & 0x80; print "$asc\n"; print "$val\n" ; my $line="我是中国人"; my $lenline= length $line; my @vec =split //,$line; my $size= scalar @vec; print "字符串的长度是 $lenline 数组的长度为$size\n" ;
|
请发表评论