$string = "hello"; $string =~ /^\s+|\s$/g; #### $string = "hello"; #### ($string = $source) =~ s/^\s+|\s$/g;