Re: lwall snippet

2004-04-11 Thread Sven Neuhaus
On Sat, Apr 10, 2004 at 08:56:26PM -0400, [EMAIL PROTECTED] wrote:
 I recently came across this impenetrable Wall code:
 
   last|perl -pe '$_ x=/(..:..)...(.*)/'$1'ge$1'$1'lt$2'
   That's gonna be tough for Randal to beat...  :-)
-- Larry Wall in  [EMAIL PROTECTED]
 
 What on earth does this do?  I get no output when I run it on my Linux
 system.  ( *gulp* )
 
 Is there any tool that would help decoding this thing?

I was going to explain it to you, but just look at Larry's original posting:
http://groups.google.com/groups?safe=imagesie=UTF-8oe=UTF-8[EMAIL 
PROTECTED]as_scoring=dlr=hl=en
aka
http://tinyurl.com/25hls

-Sven
PS: One $1 refers to the shell variable and the other one to perl's variable etc.
-- 
Said the attractive, cigar-smoking housewife to her girl-friend: I got
started one night when George came home and found one burning in the ashtray.


Re: lwall snippet

2004-04-10 Thread kynn
   X-Original-To: [EMAIL PROTECTED]
   Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
   X-Spam-Status: No, hits=0.0 required=7.0
   tests=
   X-Spam-Check-By: la.mx.develooper.com
   X-Authenticated: #163624
   Date: Sun, 11 Apr 2004 03:56:16 +0200
   From: A. Pagaltzis [EMAIL PROTECTED]
   Mail-Followup-To: [EMAIL PROTECTED]
   Content-Disposition: inline

   * Etienne Grossmann [EMAIL PROTECTED] [2004-04-11 03:19]:
On Sat, Apr 10, 2004 at 08:56:26PM -0400, [EMAIL PROTECTED] wrote:
   last|perl -pe '$_ x=/(..:..)...(.*)/'$1'ge$1'$1'lt$2'
   That's gonna be tough for Randal to beat...  :-)
-- Larry Wall in  [EMAIL PROTECTED]

The other conditions in the rhs I don't grok.

   Remember that it's shell code at the first iteration here, and as
   there's single-quotes in the middle of the Perl code, only the
   following bits are seen verbatim by Perl:

   perl -pe '$_ x=/(..:..)...(.*)/'$1'ge$1'$1'lt$2'
 ^

   The rest is interpreted by the shell -- particularly, the $1 and
   $2 not protected by anything are interpolated before Perl is even
   called.

   With a little spacing, the code reads like this:

   $_ x= /(..:..)...(.*)/  'foo' ge $1  'bar' lt $2;

   where I'm assuming that the shell's $1 was foo and its $2 was
   'bar'.

I see.  But I think you meant

   $_ x= /(..:..)...(.*)/  'foo' ge $1  'foo' lt $2;

since the shell's $2 is never used, as far as I can tell.  I still
have no clue what the shell's $1 would be in this case, other than the
empty string.

kj



Re: lwall snippet

2004-04-10 Thread Ronald J Kimball
On Sun, Apr 11, 2004 at 12:06:17AM -0400, [EMAIL PROTECTED] wrote:

 I see.  But I think you meant
 
$_ x= /(..:..)...(.*)/  'foo' ge $1  'foo' lt $2;
 
 since the shell's $2 is never used, as far as I can tell.  I still
 have no clue what the shell's $1 would be in this case, other than the
 empty string.

% cat tmp.sh
last|perl -pe '$_ x=/(..:..)...(.*)/'$1'ge$1'$1'lt$2'
% ./tmp.sh 12:00
rjk   console  rojeki.local.Sat Apr 10 11:59   still logged in
rjk   console  rojeki.local.Sat Mar 27 11:38 - 12:31  (00:53)
rjk   console  rojeki.local.Sat Mar 13 09:19 - 23:14  (13:54)
rjk   console  rojeki.local.Sun Dec  7 10:21 - 22:44  (12:22)


Ronald