($var = <<"HEREDOC") =~ s/^\s+//gm; your text goes here HEREDOC