Re: lwall snippet

"A. Pagaltzis" <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <20040411015616.GA1134@klangraum>
* 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'.

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."
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.