in reply to RFC: how to push the boundries without being annoying?

I happened to have witnessed one of these questions where you're pushing the envelope on IRC. Nobody called you stupid, but they did say: don't do that. The basic problem was the: xy problem.

You asked how to see if a value has been set on in a variable, even if it's undef. Various people tried to think of ways to do that, but many suggested defined, which you had specifically ruled out.

You were wondering how to avoid the "uninitialized value used in concatenation" error, but you didn't ask about that, you asked how to check to see if a variable had a value in it. The answer to the uninitialized value question was defined...

Do you see what I mean?

(I may have you confused with someone else. If so, sorry. I swear the guy on IRC was called exodus too.)

-Paul

  • Comment on Re: RFC: how to push the boundries without being annoying?

Replies are listed 'Best First'.
Re^2: RFC: how to push the boundries without being annoying?
by exodist (Monk) on Jan 20, 2009 at 01:26 UTC

    That was me, however I was not trying to solve the "uninitialized value used in concatenation" problem. I used that as an example of something that was able to tell if it had been set before or not. And indeed, defined did the same thing, I had assumed (incorrectly) that if I had done my $a = undef, it would have thought the value was 'initialized' and not generate that error. I chock this up to the use of uninitialized instead of undefiend in the warning message.

    I was trying to create a behavior that depended on if someone had tried to assing a value, even undef, to a variable. So 'my $a' and 'my $a = undef' would result in different behavior.

    This is of course not possible, but I did not know that, and I was very confused. Also this was in the IRC channel, and it was very hard to define my question with enough information to prevent people from assuming I was trying to do something that could be solved with the 'defined' check.

    How could I have handled this better? Was it just a communication breakdown cause I was trying to do something impossible that closely resembled something that was possible? Or did I just choose a really bad example?

      Well, you had specifically ruled out the correct answer in your question. I think the XY problem still applies. But I don't think you can handle it better than you did. There were some grumpy people around and that's part of what the IRC is about. It took less than a screen to get everything sorted out and in my mind it went pretty smoothly for being on the IRCs. I really didn't think you did anything wrong, aside from confusing us initially.

      -Paul

      Hmm - so that error message suggests that there is a difference between uninitialized and undefined. This sure is misleading.