my $line='PSAPPSRV.26476584 (6) 01/02/19 06:30:30 GetCertificate(3) Returning context. ID=PTWEBSERVER, Lang=ENG'; my $SpaceChar = ' '; my $offset = 0; my $start_at=0; my $space_ctr = 0; my $result; while ($space_ctr < 4) { $offset = index($line, $SpaceChar, $start_at); # $offset $result = substr $line,index($line, $SpaceChar, $start_at); $space_ctr++; $start_at = $offset + 1; print "Substr($offset) = $result \n"; print "space #:$space_ctr found at offset: $offset \n"; } # using a regex to parse out the piece we want: $line =~ m/\S*\s+\S*\s+\S*\s+\S*\s+(.*)/ ; # \S* is zero or more NON space chars. \s+ is one or more SPACE chars. (.*) is everything after the 4th space. saved in $1 for later use. my $wanted_substr = $1; print "Wanted String= $wanted_substr \n"; exit 1;