To determine the number of the current week in php, one line is enough

date("W", time()); 

How to do the same on pearl? Found only a couple of examples on a few lines. Couldn't it be somehow simpler?

  • Why is there only 3 letters in English "car", and 2 times more letters in Russian word "car"? Is the analogy clear? I advise you not to bother and copy those few lines. - Denis

2 answers 2

 perl -MTime::Piece -E '$t = localtime; say $t->week' 3 

    You can use the strftime() function from the POSIX package. the parameters and the result are the same:

     $ perl -e 'use POSIX qw(strftime); print strftime "%W", localtime;' 03