|Lesson 11|| Perl split function|
|Objective||Given a set of text data, write a Perl program that uses the |
split function to get just the browser name and version.
Perl Split Function
function is, in some ways, the inverse of the
function. However, it is more powerful than that description may imply, because it uses a regular expression to specify where the splits occur.
function returns a list comprising all the resulting elements from splitting a string.
Any of these forms are acceptable for invoking
split /PATTERN/, EXPR, LIMIT
split /PATTERN/, EXPR
/PATTERN/ parameter dictates where the string is split.
EXPR parameter is the string from which the split is derived.
LIMIT parameter is a number specifying the maximum pieces to split from the string (however, the split may result in fewer pieces).
LIMIT is omitted, the results will be as many pieces as may be made using the pattern to split the string; if
EXPR is omitted,
$_ string is used for the input string;
/PATTERN/ is omitted, the string is split on whitespace, after omitting any leading whitespace.
Perl Split Function - Exercise