How do I use Perl's localtime with print to get the timestamp?

后端 未结 5 564
Happy的楠姐
Happy的楠姐 2020-12-20 10:58

I have used the following statements to get the current time.

  print \"$query executed successfully at \",localtime;
  print \"$query executed successfully          


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 11:56

    scalar forces scalar context:

    print scalar localtime ();
    

    In the second example, it's clearly a list context so you're just getting a printout of the numbers in a row. For example, try

     print join (":", (localtime));
    

    and you'll see the numbers joined with a colon.

提交回复
热议问题