Perl:Split a String

From Progzoo
Jump to: navigation, search

You can use split to break a single string into an array of strings.

split

You can specify the string that delimits. split(' ',$s) will split the string $s on every run of space characters.


[Font] [Default] [Show] [Resize] [History] [Profile]

split on regular expression

You can use a regular expression. /\s+/ will match one or more consecutive white space characters - including tabs and line end markers.


[Font] [Default] [Show] [Resize] [History] [Profile]