From the course: Perl 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Splitting strings

Splitting strings - Perl Tutorial

From the course: Perl 5 Essential Training

Start my 1-month free trial

Splitting strings

- [Voiceover] The split function is used to split a string into an array of parts, using regular expressions, and if I go ahead and run this, you'll see that it splits this string up into an array, and displays each of the words separately from the array, and so split takes a regular expression as its first argument, and then the string as its second argument, and it returns a list which can be used to initialize an array or I could even just take that and put it right at the, in the for each, and run it, and we get exactly the same result. Where this comes in handy is things like, for example an IP address, if I have 192.0.5.127, and I wanna split on the period, now the period of course is a wildcard character, so if I wanna use a literal period I have to put a backslash before it, and I run that, and now I have the parts of my IP address, all in separate convenient strings in a list, or for example, let's say I had a string that had a bunch of different values separated by colons…

Contents