in reply to substring extraction

Use a regular expression. From your description, it seems that you want everything except the first and last 2 'words'. I assume that by word you mean something without whitespace. This will work for my interpretation of the problem:
use strict; use warnings; ... my $source_string; # set the value of $source_string to the original string $source_string =~ /^\S+\s+\S+\s+(.+)\s+\S+\s+\S+$/; my $wanted_string = $1;