< Perl Programming | Keywords
The split keywordEdit
split splits the EXPRESSION in a list of strings and returns this list. Without EXPRESSION, $_ is used as source. Anything in EXPRESSION that matches PATTERN is taken to be a separator, which may be longer than one character or have even zero length (results in a zero-width match). When separating the EXPRESSION, the separator itself is not added to the strings.
split /PATTERN/, EXPRESSION, LIMIT split /PATTERN/, EXPRESSION split /PATTERN/ split
$login = "anton"; $passwd = "j4\/D\\S"; $uid = 1721169842; $gid = 8421691721; $gcos = "nothing"; $home = "\\"; $shell = "ksh"; $rec = join(':', $login, $passwd, $uid, $gid, $gcos, $home, $shell); print $rec, "\n", join(':', split('8', $rec)), "\n";
split returns the colon-separated string elements, which take '8' also as a separator: