"Luke Palmer" <[EMAIL PROTECTED]> wrote: > Hans Ginzel writes: > > On Thu, Jul 08, 2004 at 09:12:16PM +1000, Gautam Gopalakrishnan wrote: > > > about string subscripting. Since $a[0] cannot be mistaken for array subscripting > > > anymore, could this now be used to peep into scalars? Looks easier than using > > > > Are there plans in Perl 6 for string modifiers? > > Not exactly. But method calls can be interpolated into strings, so most > of this is pretty straightforward: > > > As they are in bash eg.: > > ${var%glob_or_regexp} > > ${var%%glob_or_regexp} > > my $newfile = "$str.subst(rx|\.\w+$|, '')\.bin"; > > > ${var#glob_or_regexp} > > ${var##glob_or_regexp} > > say "Basename is $str.subst(rx|.*/|, '')" > Would that not be:-
say "Basename is $(str.subst(rx|.*/|, ''))" I thought when you were interpolating method calls you had to put brackets $(object.meth), so that you could still write things like:- $fh = open "$id.txt"; # OK, maybe my open syntax isn't right Or is it that you can do:- say "$object.meth()"; But not:- say "$object.meth"; And the later (...) distinguish that we are doing a method call? Or am I completely wrong? :-) Thanks, Jonathan > > ${var/pattern/string} > > say "$str.subst(rx|foo|, 'bar')" > > > ${var:[+-=]word} > > # ${var:-word} > say "You chose $($value // 'no value')"; > > # ${var:=word} > say "You chose $($value //= 'no value')"; > > # ${var:?word} > say "You chose $($value // die 'please choose a value')" > > Luke > >