Re: s/// in string context should return the string

2003-11-21 Thread Larry Wall
On Fri, Nov 21, 2003 at 01:26:18PM +, Piers Cawley wrote: : Simon Cozens <[EMAIL PROTECTED]> writes: : : > [EMAIL PROTECTED] (Luke Palmer) writes: : >> $substituted = ($text ~~ s/$pattern/$replacement/) but nothing; : > : > Surely "no buts"? :) : > : >> What I really want is a functional v

Re: Control flow variables

2003-11-21 Thread Larry Wall
On Thu, Nov 20, 2003 at 07:27:56PM -0600, Jonathan Scott Duff wrote: : On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote: : > One wonders what the return value of a loop will be: : > : > my $what = do { : > while $cond {...} : > } : : I would expect it to be the value of

Re: s/// in string context should return the string

2003-11-21 Thread Piers Cawley
Simon Cozens <[EMAIL PROTECTED]> writes: > [EMAIL PROTECTED] (Luke Palmer) writes: >> $substituted = ($text ~~ s/$pattern/$replacement/) but nothing; > > Surely "no buts"? :) > >> What I really want is a functional version of s///. Like: >> my $substituted = $text.s(/$pattern/, { $replace

Re: s/// in string context should return the string

2003-11-21 Thread A. Pagaltzis
* A. Pagaltzis <[EMAIL PROTECTED]> [2003-11-21 13:16]: > But that without nested for modifiers (will those work?) this > isn't be applicable in the middle of a map map map map chain.. I shouldn't edit my stuff so heavily.. what a mess. -- Regards, Aristotle "If you can't laugh at yourself, you

Re: s/// in string context should return the string

2003-11-21 Thread A. Pagaltzis
* Smylers <[EMAIL PROTECTED]> [2003-11-20 11:50]: > This, however, is irritating: > > my @new = map { s:e/$pattern/$replacement/; $_ } @old; > > I forget the C<; $_> far more often than I like to admit and > end up with an array of integers instead of modified strings. > So I'd like a more eleg

Re: s/// in string context should return the string

2003-11-21 Thread Simon Cozens
[EMAIL PROTECTED] (Luke Palmer) writes: > $substituted = ($text ~~ s/$pattern/$replacement/) but nothing; Surely "no buts"? :) > What I really want is a functional version of s///. Like: > my $substituted = $text.s(/$pattern/, { $replacement }); > Without modifying $text. $rubyometer++;

Re: s/// in string context should return the string

2003-11-21 Thread Piers Cawley
Luke Palmer <[EMAIL PROTECTED]> writes: > Smylers writes: >> Perl 5 C currently returns the number of substitutions made. >> This has its uses, so Perl 6 C should probably continue to do >> this. >> >> Can we have a return value that stringifies to the result of the >> substitution but numifies to

Re: Control flow variables

2003-11-21 Thread Jonathan Scott Duff
On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote: > No. gather{} is a generator (assuming nothing about its name or > existance whatsoever). It runs some code, gathering up each pick() > (same assumption) into a list, and returning that. Thanks for the post Luke. I'd seen what Larry