The substr operator can be used to split or cut a string into pieces. For example, let's say you have a variable that contains the text HelloWorld.
my $string = "Hello World";
substr can be used to cut this string into pieces. In this example, character 1 (the H in Hello) will be replaced with the letter A.
substr($string, 0, 1) = "A";
In this example, the $greeting variable will contain the text "Hello" and the $planet variable will contain the text "World".
my $greeting = substr $string, 0, 5; my $planet = substr $string, 5, 5;