Try this code, and modify as u required. i think this will enough for ur doubt.
$a="flintstones husband fred pal barney wife wilma pet dino";
if ($a) {
$a=~/^(.*?)\s/;
print $1;
}
We prefer that people show some effort before doing their code/work for them.