Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: scalar subscripting

3 views
Skip to first unread message

Hans Ginzel

unread,
Jul 13, 2004, 2:59:22 AM7/13/04
to perl6-l...@perl.org
On Fri, Jul 09, 2004 at 05:02:48PM +0100, Jonathan Worthington wrote:
> > > Are there plans in Perl 6 for string modifiers?
> > Not exactly. But method calls can be interpolated into strings, so most
> > > As they are in bash eg.:
> > > ${var%glob_or_regexp}
> > > ${var%%glob_or_regexp}
> >
> > my $newfile = "$str.subst(rx|\.\w+$|, '')\.bin";

But what about the value of $str after interpolation?
In shall it stays it's original value! I would often need,
to use a little modified value of $str for a particular expression.
I like the way shell does it, to be able to write it such short,
without any other explicit variable.

Best regards
Hans

--
Why PHP? See man HTML::Embperl from libhtml-embperl-perl.deb!
http://perl.apache.org/embperl/

Luke Palmer

unread,
Jul 13, 2004, 9:15:09 AM7/13/04
to perl6-l...@perl.org
> > > my $newfile = "$str.subst(rx|\.\w+$|, '')\.bin";
>
> But what about the value of $str after interpolation?
> In shall it stays it's original value! I would often need,
> to use a little modified value of $str for a particular expression.
> I like the way shell does it, to be able to write it such short,
> without any other explicit variable.

Yeah, the fact that substitutions were only destructive in Perl 5 was a
major kludge. I was taking the .subst method there as a functional,
non modifying version. So:

$str.subst(...) # returns substituted string, leaves $str alone
$str.=subst(...) # modifies $str

Luke

0 new messages