my $var = "1 word here another word"; my @words = split /\s+/, $var; #### my $var = ' some words '; $var =~ s/\A \s* (.*) \s* \z /$1/x;