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|.*/|, '')" > ${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