Re: lwall snippet

<[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
   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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.