胖鸭 2010-05-24 18:40
浏览 242
已采纳

的 print 如何在默认情况下添加一个新行?

In Perl most of my print statements take the form

print "hello." . "\n";

Is there a nice way to avoid keeping all the pesky "\n"s lying around?

I know I could make a new function such as myprint that automatically appends \n, but it would be nice if I could override the existing print.

转载于:https://stackoverflow.com/questions/2899367/how-can-perls-print-add-a-newline-by-default

  • 写回答

8条回答 默认 最新

  • 衫裤跑路 2010-05-24 18:47
    关注

    Perl 6 has the say function that automatically appends \n.

    You can also use say in Perl 5.10 or 5.12 if you add

    use feature qw(say);
    

    to the beginning of your program. Or you can use Modern::Perl to get this and other features.

    See perldoc feature for more details.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app