How would I do this in Perl6? #1

2004-09-14 Thread Michele Dondi
Dear all, I've recently thought of a possible syntax extension for (Perl5's) [un]pack() and I posted my RFC to clpmisc where it didn't have much success, I must say. However I'm not interested in proposing it here, only I would like to investigate a possible Perl6 technique inspired by those

But is it intuitive?

2004-09-14 Thread Austin Hastings
I was thinking about removing files this morning, and realized that I wish rm supported inclusion/exclusion. In particular, I wanted to remove * but not Makefile (since my Makefile uses lwp-download to re-fetch the source code, etc.) It occurred to me to wonder: can P6's cbut do the same

Re: But is it intuitive?

2004-09-14 Thread Abhijit Mahabal
On Tue, 14 Sep 2004, Austin Hastings wrote: I was thinking about removing files this morning, and realized that I wish rm supported inclusion/exclusion. In particular, I wanted to remove * but not Makefile (since my Makefile uses lwp-download to re-fetch the source code, etc.) It occurred

Re: But is it intuitive?

2004-09-14 Thread Mark J. Reed
On 2004-09-14 at 08:40:55, Austin Hastings wrote: In particular, I wanted to remove * but not Makefile (since my Makefile uses lwp-download to re-fetch the source code, etc.) Well, you can, depending on your shell: in ksh: rm !(Makefile) in bash: ditto, but you have to turn on the extglob

Re: But is it intuitive?

2004-09-14 Thread Luke Palmer
Abhijit Mahabal writes: On Tue, 14 Sep 2004, Austin Hastings wrote: I was thinking about removing files this morning, and realized that I wish rm supported inclusion/exclusion. In particular, I wanted to remove * but not Makefile (since my Makefile uses lwp-download to re-fetch the

Re: But is it intuitive?

2004-09-14 Thread Austin Hastings
Luke Palmer wrote: Judging from this, maybe we ought to have :not. Anyway, it's still possible: $my_rex = rx/fo*/ none(rx/^foo$/); For sure. On a side note, there should be a negating match operator for use inside: rx/\d+/ none(rx/1984/) could get awfully long if you had to handle

Re: But is it intuitive?

2004-09-14 Thread Aaron Sherman
On Tue, 2004-09-14 at 10:11, Abhijit Mahabal wrote: On Tue, 14 Sep 2004, Austin Hastings wrote: That is, can I say: $my_rex = qr/fo*/ but not 'foo'; The word junction came to my mind as I read your mail. $my_rex = qr/fo*/ qr:not/foo/; Of course, the regex itself can do this:

Re: How would I do this in Perl6? #1

2004-09-14 Thread Aaron Sherman
On Tue, 2004-09-14 at 06:45, Michele Dondi wrote: [... snip ...] Now I want to take a list of templates, say $t1, ... $tn and get the result of $result = pack $tn, ... pack $t2, pack $t1, @input; Assuming Perl 6 has a pack, which it may not: for @t { $result =

Re: But is it intuitive?

2004-09-14 Thread Juerd
Aaron Sherman skribis 2004-09-14 14:02 (-0400): qr{(fo*) ({$1 ne 'foo'})} What is the second set of parens for? Will the following suffice? rx/ (fo*) { $1 ne 'foo' } / And it is because of the lack of anchors that this won't work as expected? rx/ !before foo fo* / Juerd

Re: But is it intuitive?

2004-09-14 Thread Larry Wall
On Tue, Sep 14, 2004 at 02:02:22PM -0400, Aaron Sherman wrote: : Of course, the regex itself can do this: : : qr{(fo*) ({$1 ne 'foo'})} Er, at the moment bare closures don't care about their return value, so as it currently stands, you'd want something more like: rx/(fo*) {fail if $1

Re: But is it intuitive?

2004-09-14 Thread Larry Wall
On Tue, Sep 14, 2004 at 08:30:45PM +0200, Juerd wrote: : Aaron Sherman skribis 2004-09-14 14:02 (-0400): : qr{(fo*) ({$1 ne 'foo'})} : : What is the second set of parens for? Will the following suffice? : : rx/ (fo*) { $1 ne 'foo' } / Bare closures are used only for their side effects

Re: But is it intuitive?

2004-09-14 Thread Aaron Sherman
On Tue, 2004-09-14 at 14:40, Larry Wall wrote: On Tue, Sep 14, 2004 at 02:02:22PM -0400, Aaron Sherman wrote: : Of course, the regex itself can do this: : : qr{(fo*) ({$1 ne 'foo'})} Er, at the moment bare closures don't care about their return value, so as it currently stands, you'd

Re: How would I do this in Perl6? #1

2004-09-14 Thread Michele Dondi
On Tue, 14 Sep 2004, Aaron Sherman wrote: Assuming Perl 6 has a pack, which it may not: I know: this is one of the reasons why I wrote (hopefully *clearly* enough) that I was just using it as an example. A user defined pack() whoud do just the same here, anyway. for @t {

Re: How would I do this in Perl6? #1

2004-09-14 Thread Matt Diephouse
On Tue, 14 Sep 2004 12:45:17 +0200 (CEST), Michele Dondi [EMAIL PROTECTED] wrote: Now I want to take a list of templates, say $t1, ... $tn and get the result of $result = pack $tn, ... pack $t2, pack $t1, @input; without actually writing the whole thing. To my knowledge and great