Okay. I do have a feeling that you pose your questions to show this $^M stuff as a crufty corner of Perl instead of to learn about memory allocation issues. If that is the case; I agree with you: it's a crufty corner. If not perhaps these answers will help.

1. If your die handler doesn't function as you expect when you force a memory scarcity situation on your process.

2. Big enough to contain all the thingies you create in your die handler.

3. Watching memory usage of the process. Seeing your handler start working when it didn't in a memory scarcity situation.

As a demo your sample is about all there is to it. Set $^M to the space you may need. The rest is automagical, except figuring out what size to set it.

How often is this an issue? See #1 above; how often do people feel the need to do resource scarcity testing? How often do people recompile Perl to enable odd features? How often do people use signal handlers? Most people--never.

Your estimate question and somewhat similar statements in this thread make me feel you expect too much of this mechanism. You don't go into your die handler, then jump back to your program to live again. Instead you use the memory to die in an effective manner, you use it to say your last words.

Be well,
rir


In reply to Re^9: Is $^M a leftover April Fool? by rir
in thread Is $^M a leftover April Fool? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.