Perl_获得字符串长度_length($var)

Perl_获得字符串长度_length($var)

 

例:
my $var='\\';  #此处'与"括着的\\颜色一样
my $var1="\\";
my $len=length($var);
my $len1=length($var1);
print $len."\t".$len1."\n";
#输出1\t1\n
$var='\n';  #此处'与"括着的\\颜色不一样;
$var1="\n";
$len=length($var);
$len1=length($var1);
print $len."\t".$len1."\n";
#输出2\t1\n
$var='\'';  #此处'与"括着的\\颜色一样;
$var1="\'";
$len=length($var);
$len1=length($var1);
print $len."\t".$len1."\n";
#输出1\t1\n
$var='\"';  #此处'与"括着的\\颜色不一样;
$var1="\"";
$len=length($var);
$len1=length($var1);
print $len."\t".$len1."\n";
#输出2\t1\n
$var='\;';  #此处'与"括着的\\颜色不一样;
$var1="\;";
$len=length($var);
$len1=length($var1);
print $len."\t".$len1."\n";
#输出2\t1\n

你可能感兴趣的:(Perl技巧,perl)