# If able to delete the stuff(.*) between the beginning # of the line(^) and the word 'alias' and one-or-more spaces(\s+) # found after that ... if (s/^.*?alias\s+//) { # Extract the 1st, 5th and 7th "words" my ($varalias, $varsource, $vartarget) = (split(' '))[1,5,7]; # Then whatever... }