my $k = ''; # A bunch of junk happens to this scalar before this point my $t = "\ttest \n \n"; ($k) .= $t =~ /^\s*(.*?)\s*$/g; print $k ."\n";