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 -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -