","a","b","c");print "\n"' a=>b=>c /home/lee#perl -e 'print join(":","a"," name="description" />

join and split

发表于:2007-05-26来源:作者:点击数: 标签:
join用于将表中的元素连接成串,split是串拆分成表 join语法: join E XP R,LIST 如: /home/lee#perl -e 'print ("a","b","c");print "\n"' abc /home/lee#perl -e 'print join("=>","a","b","c");print "\n"' a=>b=>c /home/lee#perl -e 'print join(":","a",
join用于将表中的元素连接成串,split是串拆分成表

join语法:
join EXPR,LIST
如:
/home/lee#perl -e 'print ("a","b","c");print "\n"'
abc
/home/lee#perl -e 'print join("=>","a","b","c");print "\n"'
a=>b=>c
/home/lee#perl -e 'print join(":","a","b","c");print "\n"'
a:b:c
join函数让EXPR中的值包围着LIST里的串,然后返回整个串!EXPR也可以拥有多个字符!

split语法:
split
split /PATTERN/
split /PATTERN/,EXPR
split /PATTERN/,EXPR,LIST
这里,split函数在串PATTERN出现的每个地方将串EXPR分开.例子:
/home/lee#perl -e 'print ((split " ","hello world")[1]);print "\n"'
world

原文转自:http://www.ltesting.net