in reply to Why are list items passed to die() combined into a string?

For some somewhat more useful discussion of this expected behavior (I find the docs poor on this one), see Re: Perl's Warn and Die Signals and its links.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

  • Comment on Re: Why are list items passed to die() combined into a string?

Replies are listed 'Best First'.
Re^2: Why are list items passed to die() combined into a string?
by Lotus1 (Vicar) on Jan 13, 2015 at 18:52 UTC

    Thanks, that verifies what I see. I had read the article that node was in response to but I didn't make it down that far. Another node states that die() is just doing what print() does and concatenates its inputs for display.

    Update:

    I found the following at General Variables in the %SIG section:

    The routine indicated by $SIG{__DIE__} is called when a fatal exception is about to be thrown. The error message is passed as the first argument.
      Thing to note: neither $" or $, will impact the concatenation seen by $SIG{__DIE__}(e.g. join '', @_). This contrasts print, where print "@_" or print @_ can have their behavior impacted.

      I far prefer overriding die to working with $SIG{__DIE__} myself, since the latter's behavior isn't what I usually actually want to impact.


      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        Ah, good point. Overriding functions will be my next project.

        I had considered using "@_" to pass to my email routine just to let my future self know it needs to be a single string. But since @_ has already been concatenated that doesn't make sense. Now I'm thinking passing $_[0] might be better.