www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/02/02/09:11:39

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.9 required=5.0 tests=BAYES_40,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Ronald Fischer <fischerr DOT external AT infineon DOT com>
Subject: Re: Finding either boot time or login time
Date: Mon, 2 Feb 2009 14:11:11 +0000 (UTC)
Lines: 16
Message-ID: <loom.20090202T140523-18@post.gmane.org>
References: <loom DOT 20090130T125737-221 AT post DOT gmane DOT org> <4982FB77 DOT 7020505 AT byu DOT net> <loom DOT 20090130T152913-409 AT post DOT gmane DOT org> <5 DOT 2 DOT 0 DOT 9 DOT 1 DOT 20090130164221 DOT 01ec8dd0 AT localhost> <f60fe000901300757l23e6466bu4250f71c8593013d AT mail DOT gmail DOT com>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Mark J. Reed <markjreed <at> gmail.com> writes:

> One-liner to display the boot time:
> 
> $ perl -lane 'print ~~localtime(time-$F[0])' /proc/uptime

Thanks a lot! This is great!

Would you mind explaining the ~~ trick? localtime returns a list, so 
I would have concluded that applyiing ~ to this list would force it
into scalar context, so it would bitwise negate the number of elements
in the list. But this is obviously not done, because just by 
trying out your code, I see that it works.

Ronald



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019