use warnings; use strict; my $column = 6; my $delim = " "; my $s = qq(a bb ccc dddd eeee fff gggggg hh i jjjjjjjj); my($result) = $s =~ /(([^$delim]*)$delim?){$column}/; print $result, "\n";