Questions about this topic? Sign up to ask in the talk tab.

Perl/Basics/Variables and Data Types/Helper Functions/Split

From NetSec
Jump to: navigation, search

Split takes a scalar and converts it to an array using a delimiter. Using our string from earlier:

<syntaxhighlight lang="perl">my $joined_message = "Hello world!\n, I like perl!\n"; my @messages = split('/, /',$joined_message); print $messages[0]; print $messages[1]; print "Size of messages array: ". $#messages . "\n";</syntaxhighlight>