perl - Eliminate intermediate variable when combining here document, substitution and die -


is possible eliminate use of intermediate variable $msg in example?

($msg = <<'end_msg') =~ s/\n//gm; super error message happens span on multiple lines want print without newlines. end_msg die $msg; 

if did not need remove newlines, directly die <<'end_msg'; ... have not found way combine these 2 approaches.

with perl 5.14 or newer can,

die <<'end_msg' super error message happens span on multiple lines want print without newlines. end_msg =~ s/\n//gr; 

edit: or

die <<'end_msg' =~ s/\n//gr .. end_msg 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -