Perl Monk, Perl Meditation | |
PerlMonks |
How use $^M?by xiaoyafeng (Deacon) |
on Apr 05, 2021 at 13:30 UTC ( [id://11130839]=perlquestion: print w/replies, xml ) | Need Help?? |
xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
perl lack global variable/memory for use.But when I look up the doc I find $^M seem to meet this requirement. Below is the introduction of $^M
By default, running out of memory is an untrappable, fatal error. However, if suitably built, Perl can use the contents of $^M as an emergency memory pool after "die()"ing. Suppose that your Perl were compiled with "-DPERL_EMERGENCY_SBRK" and used Perl's malloc. Then $^M = 'a' x (1 << 16); would allocate a 64K buffer for use in an emergency. But I can't find any excerpt code about this variable. Could someone show code about this? Thanks in advance!UPDATE: Sadly, $^M is not for usage of global memory as I expect. It's only for a seldom scenario: when perl is out of memory even can't call die signal function to clean up, then if you define $^M already, perl would free $^M first and gain memory to clean up. I didn't try it though, but if you are interested in it, you can refer Is $^M a leftover April Fool? to get more discussion about $^M. I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
Back to
Seekers of Perl Wisdom
|
|