in reply to Re^6: Is $^M a leftover April Fool?
in thread Is $^M a leftover April Fool?

Flip it around.
  1. You're in a death handler.
  2. You have no idea why you're there.
  3. Since it could be any reason, you have very little that you can count on.
  4. By using $^M, you have a certain amount of memory you can work with that you can count on. This is to make sure that your death handler will still work if you ran out of memory.
  5. It has no purpose otherwise. It doesn't provide any protection against other reasons you might be in a death handler.
  6. The chance it will be useful is OS and app dependent.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re^8: Is $^M a leftover April Fool?
by BrowserUk (Patriarch) on Jan 07, 2005 at 05:35 UTC

    Okay, so the number of runs of a Perl program in which this feature comes into play approximates to:

    Count *every* run, of *any* perl program, *anywhere*.

    Divide by that number where $^M was set.

    Divide by that number that a death handler was entered at some point.

    Divide by that number that ran out of memory at that *at that point*.

    Divide by that number that are running on an appropriate OS.

    Divide by that number that constitute an application the might benefit.

    If 10% had $^M set, and 10% of those enter a death handler at some point, and 10% of those coincidentally run out of memory, and 10% of those are running on an appropriate OS and 10% of those could benefit from their death handlers not running out of memory before dying,

    I make that 0.001% of perl scripts that might benefit, which makes my million to 1 shot guess look prescient.

    If, like me, you consider that 10% is at least an order of magnitude too high for at least 2 of those, and 2 orders of magnitude to high for a third, then you the figure is more like 0.0000001%, which makes the million to one shot look positively optimistic.

    Anyone want to buy some alien abduction insurance? :)


    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.
      How many scripts use the dbmopen function? You can point to at least half the features in Perl and realize that less than 1% of all scripts in existence directly use that code. In many cases, probably much less than that.

      Granted, $^M is a very obscure and esoteric feature, but so is dbmopen ...

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        This is all getting way academic now, but if your estimate of those that use dbmopen is anything like correct, that's 1 in 100.

        Whereas if my guesses for $^M are anything like correct, we are talking 1 in 100,000 to 1 in 100,000,000.

        Even if every programmer added a $^M reserve to every script they ever wrote, your still only looking at 1 in 10,000 to 1 in 10,000,000.

        Another difference is that dbmopen has been superceded. Before tie and all modules that use it became available, I think dbmopen was probably a lot more used. If you count the number of programs that use some form of tie, or tie-based module, your 1% is probably an under-estimate. Tie::File alone could probably manage 1%.

        Nothing has superceded $^M.


        Examine what is said, not who speaks.
        Silence betokens consent.
        Love the truth but pardon error.