Perl : localtime with print

Posted by kiruthika on Stack Overflow See other posts from Stack Overflow or by kiruthika
Published on 2010-04-07T11:31:36Z Indexed on 2010/04/07 13:23 UTC
Read the original article Hit count: 262

Filed under:

Hi all,

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

  print "$query executed successfully at ",localtime;
  print "$query executed successfully at ",(localtime);
  print "$query executed successfully at ".(localtime);

Output

 executed successfully at 355516731103960
 executed successfully at 355516731103960
 executed successfully at Wed Apr  7 16:55:35 2010

The first two statements are not printing the current time in a date format. Third statement only giving the correct output in a date format.

My understanding is the first one is returning a value in scalar context,so it is returning numbers.

Then in the second print I used localtime in list context only,why it's also giving number output.

© Stack Overflow or respective owner

Related posts about perl