in reply to Re: Can't I chop the lvalue of join?
in thread Can't I chop the lvalue of join?

I hadn't used join with an in-lined map before. You're right, it's so damned obvious given the way i used join with keys, but I just couldn't see that until it was pointed out to me.

Thanks a lot japhy.

PS: not that it really matters any more, but is there a reason *why* chop only works on a variable rather than any scalar lvalue?

  • Comment on Re: Re: Can't I chop the lvalue of join?

Replies are listed 'Best First'.
Re: Re: Re: Can't I chop the lvalue of join?
by japhy (Canon) on Sep 28, 2002 at 15:36 UTC
    It does work on lvalues. But the return value of join() is not an lvalue. You can't assign to it. join('x', qw( a b c )) = "foo"; is a syntax error, whereas substr($x, 2, 4) = "ouch"; is not, so you can say chop(substr($x, 2, 4)).

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

      (Which, of course, is in this case a silly way to say the same as:)
      substr($x, 4, 1) = ''; # or substr($x, 4, 1, '');

      Makeshifts last the longest.