$msg在这个例子中是否可以消除中间变量的使用?
($msg = <<'END_MSG') =~ s/\n//gm;
My super error message
Which happens to span over multiple lines
But that I want to print without newlines.
END_MSG
die $msg;
Run Code Online (Sandbox Code Playgroud)
如果我不需要删除换行符,我可以直接执行,die <<'END_MSG'; ...但我还没有找到将这两种方法结合起来的方法.
使用perl 5.14或更新版本,你可以,
die <<'END_MSG'
My super error message
Which happens to span over multiple lines
But that I want to print without newlines.
END_MSG
=~ s/\n//gr;
Run Code Online (Sandbox Code Playgroud)
编辑:或
die <<'END_MSG' =~ s/\n//gr
..
END_MSG
Run Code Online (Sandbox Code Playgroud)