q(string in q); 相当于'string in q'
qq(string in qq);相当于“string in qq"
()可换为<>,{},[]等匹配对字符qq{string in qq};
字符串中也可以出现qq[string [in] qq];
也可以换为任意//,;;,等相同字符对 qq/string in qq/
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ cat qq.pl
-
#!/usr/bin/perl
-
$var=1;
-
print q(the $var\n);
-
print qq(is $var\n);
-
print qq;
-
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./qq.pl
-
the $var\nis 1
-
string "str" (var in qq)
-
Administrator@2012-0521-2127 ~
串处理函数:chop截取最后字符,chomp截取换行符
-
#!/usr/bin/perl
-
$a="abcd";
-
chop($a);
-
print "chop $a\n";
-
print "\n";
-
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chop abc
-
-
#!/usr/bin/perl
-
$a="abcd";
-
chomp($a);
-
print "chomp $a\n";
-
print "\n";
-
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chomp abcd
-
-
#!/usr/bin/perl
-
$a="abc\n";
-
chop($a);
-
print "chop $a|";
-
print "\n";
-
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chop abc|
-
-
#!/usr/bin/perl
-
$a="abc\n";
-
chomp($a);
-
print "chomp $a|";
-
print "\n";
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chomp abc|
-
-
-
#!/usr/bin/perl
-
$a="ab\n\n\n";
-
$/="";
-
chomp($a);
-
print "chomp $a\n";
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chomp ab
-
-
#!/usr/bin/perl
-
$/="cd";
-
$a="abcd";
-
chop($a);
-
print "chop $a|";
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chop abc|
-
-
#!/usr/bin/perl
-
$a="abcd";
-
chomp($a);
-
print "chomp $a|";
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
chomp abcd|
字符串连接用 .
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ cat chp.pl
-
#!/usr/bin/perl
-
$a="hello".' '."world";
-
$b="hello"."\n"."world";
-
$c="Z".5*7;
-
print "$a\n$b\n$c";
-
-
Administrator@2012-0521-2127 ~/wesoft/perl
-
$ ./chp.pl
-
hello world
-
hello
-
world
-
Z35
阅读(33687) | 评论(0) | 转发(0) |