Front page | perl.fwp |
Postings from April 2008
Re: YN golf
Thread Previous
From:
Philippe Bruhat
Date:
April 1, 2008 00:10
Subject:
Re: YN golf
On Mon, Mar 31, 2008 at 11:37:05PM -0500, Chris Dolan wrote:
> On Mar 31, 2008, at 6:54 PM, Philippe Bruhat (BooK) wrote:
>> On Mon, Mar 31, 2008 at 04:34:58PM -0700, Rick Klement wrote:
>>>
>>> perl -le 'print for glob"{Y,N}"x5'
>>>
>>
>> Of course you have to run this in a directory that doesn't contain
>> any file matching /^[YN]{5}$/.
>
> Not true. The {} notation doesn't care whether files of that name
> actual exist. I tested like so on Mac:
I was pretty sure I tried the same manipulation to obtain all permutations
of some series of strings, and that it didn't work as expected when one of
the permutations actually existed as a file in the current directory.
After a quick check, you are right and I was too. :-)
What I tried was:
$ touch YYYYY
$ perl -le 'print for glob"[YN]"x5'
YYYYY
I computed my permutations with square brackets (which is one character
shorter, but more fragile).
--
Philippe Bruhat (BooK)
To flaunt your strength is to make it your weakness.
(Moral from Groo The Wanderer #25 (Epic))
Thread Previous