Why is perl so derpy?

All things Programming
Post Reply
User avatar
Naib
Site Admin
Posts: 928
Joined: Sat Dec 19, 2020 2:20 am

Why is perl so derpy?

Post by Naib »

https://www.jwz.org/blog/2020/08/the-da ... 78th-2020/

Code: Select all

% perl -e 'use Date::Parse; use POSIX; my @t = localtime; print strftime ("%a Mar ", @t) . int (1 + 0.5 + ((str2time (strftime ("%Y-%m-%d 3:00", @t)) - str2time ("2020-03-01 3:00")) /(60*60*24))) . strftime (" %X %Z 2020\n", @t);'
Tue Mar 325 15:41:23 GMT 2020
The best argument against democracy is a five-minute conversation with the average voter

Great Britain is a republic, with a hereditary president, while the United States is a monarchy with an elective king
User avatar
antae
Director of Sandbags
Posts: 431
Joined: Sat Dec 19, 2020 8:49 am

Re: Why is perl so derpy?

Post by antae »

The number after month name is a count of days since "2020-03-01 3:00". No idea why the man who wrote that oneliner counts days since that date

btw, oneliners are amazing:

Code: Select all

ls -al /tmp/huge.log.gz | perl -pe 's;(?<=\d)(\d{3})(?=(\d{3})*(\D|$));.$1;g;'
-rw-------  1 user user 667.030.687 Apr 14 11:06 huge.log.gz
My opinion ^_^ may differ from yours. That's OK. Difference makes us humans, not robots.
Post Reply