You simply want to use ($first) = $line =~ /(\S*)/;