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.

It certainly didn't start out that way. I originally came across $^M when I had a program that was occasionally dying through memory exhaustion. I went looking for a mechanism by which I could

  1. find out the circumstances that caused it.
  2. would allow me to take some action to prevent data loss by closing and flushing my open files etc.
  3. if possible, perform some action that would allow the process to recover and continue.

At the point where I posted the OP, had reached the conclusion that $^M could not be used for any of these purposes. No matter how many times I read what documentation there is, or searched the related source code, nor any of my various attempts a deviousness, nothing I did would allow me to use the only feature of perl that appeared to show (and still shows), some promise for tackling one or more of these goals.

So I made my original post in the hope that someone would explain what I was doing wrong or misunderstanding. That's where things stood until you recently re-opened the notion.

Since your post, I have re-covered some of the ground I went through originally before posting, and pretty much arrived at the same place.

Except that I now realise that whilst it is probably down to my stupidity that I misunderstood the purpose of $^M (though the documentation could be clearer in stating not just what it does, by why, and how a Perl programmer might make use of it), the actual use of it is somewhat (actually a lot) suspect.

Whilst, with some effort, it would be possible to engineer the circumstances under which the provision of a $^M memory reserve would be utilised, the chances of it ever actually occuring in the wild are somewhere between slim and none. And the benefits of its utilisation even slimmer.

Which is a shame, because given that the runtime will know when it is being called upon to make use of the reserve, the provision of a __MEM__ pseudo-signal could allow for the first 2 of the goals listed above to be realised. And under some circumstances, the last might also be achievable.

(I know, "Where's the patch!" :)

I'll shut up now!


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

In reply to Re^10: Is $^M a leftover April Fool? by BrowserUk
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.