in reply to Re^2: Use of uninitialized value in substr
in thread Use of uninitialized value in substr

This is not about " concatenating undef to a string.".

That's exactly what happens to the 4th arg of substr.

Yes, you could suppress it, but why should you have to for something that could not possibly by "by accident".

eh? Of course you can pass an undefined value to substr by accident.

The real question is about making explicit undef semantically different from indirect undef

ah! There wasn't even an allusion to this. It's not even an existing concept in Perl as far as anyone is concerned. (Yes, I'm aware there's an instance where literal undef is special in an obscure and unused usage of a builtin, but it's not info I keep in my mind.)

No thanks for this feature. The following come to mind:

It's not one of those cases where I can'tcan provide concrete explanation or example. It just reeks of trouble.

Update: Spelled out some of the reasons.

  • Comment on Re^3: Use of uninitialized value in substr

Replies are listed 'Best First'.
Re^4: Use of uninitialized value in substr
by BrowserUk (Patriarch) on May 03, 2010 at 16:20 UTC
    That's exactly what happens to the 4th arg of substr.

    No it's not!. It replaces (a potentially null), part of the target string. That is not concatenation. Maybe a limitaion of your english?

    Of course you can pass an undefined value to substr by accident..

    Did I say you couldn't? What don't you understand about "explicit undef"?

    ah! There wasn't even an allusion to this..

    You think? Read again.

    It's not one of those cases where I can't provide concrete explanation or example. It just reeks of trouble..

    Ha! Do it! But you won't be getting counter-argument from me. Been down that road to many times and it is pointless.

    You always arrive at a conclusion and then set out to prove it, rather than examine the up & downsides and then reach a conclusion.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      It replaces (a potentially null), part of the target string. That is not concatenation.

      Replacing part of a string means concatenating the part that precedes the replacement with the replacement, and that with what follows the replacement.

      Did I say you couldn't?

      "why should you have to for something that could not possibly by "by accident""

      Read again.

      Done. Still don't see it. Not in the OP.

      Ha! Do it!

      Sorry, typo. I meant "It's not one of those cases where I can'tcan provide concrete ..."

      rather than examine the up & downsides and then reach a conclusion.

      Why do you bother commenting if you think I just make stuff up. You asked for our opinion, so I gave mine. I've already added five of my reasons to the post.

        "why should you have to for something that could not possibly by "by accident""

        Explain. How could your use of undef in your example, be "by accident"?

        $s = substr($s,0,1) . undef . substr($s,3);

        The rest. Equally misjudged.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
        A reply falls below the community's threshold of quality. You may see it by logging in.