|
发表于 2004-4-14 16:28:07
|
显示全部楼层
这里有split 的解释。在置顶也有些例子。。。
- split ([/PATTERN/], [EXPR], [LIMIT])
- Category: Array, Regular Expression
- Return Value in Scalar Context: Not recommended, but it returns the number of fields found and stored the fields in the @_ array.
- Return Value in Array Context: A list of fields found in EXPR or $_ if no expression is specified.
- Definition: Splits a string expression into fields based on the delimiter specified by PATTERN. If no pattern is specified whitespace is the default. An optional limit restricts the number of elements returned. A negative limit is the same effect as no limit. This fuNCtion is often used in conjuNCtion with join() to create small text databases.
- @fields = split(/:/, "1:2:3:4:5");
复制代码
- #!/usr/bin/perl -w
- #@list=split(parrern,sting,maxlength);
- #
- @text=("well","hello,the world","how","do","you","do");
- print "@text\n";
- @name=split(/,/,@text,2);
- print "@name\n";
- print "@text\n";
- $abc = "apile:fjkdfk:300:500:XXX:/bin/bash";
- @abc = split(/:/,$abc);
- print "@abc\n";
复制代码 |
|