develooper Front page | perl.fwp | Postings from December 2001

Re: The Santa Claus Golf Apocalypse

Thread Previous | Thread Next
From:
Karsten Sperling
Date:
December 6, 2001 15:46
Subject:
Re: The Santa Claus Golf Apocalypse
Message ID:
E16C8DE-0000tR-00@mailgate.rz.uni-karlsruhe.de
> On Fri, Dec 07, 2001 at 10:01:05AM +1100, Andrew.Savige@ir.com wrote:
>> --- mid.pl  ---------------------------------------------
>> #!/usr/bin/perl -p0
>> $_=$1while/.^(.+)^/ms
> Someone want to explain why this works?

It repeatedly keeps everything but the first and last
line of the file, thus removing the first and last line.

The first . prevents the ^ from matching at the beginning
of the string, making it match at the beginning of the
second line instead.

The trailing ^ stops the (.+) from matching everything,
keeping the last line out of the match.

- Karsten


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About