I think I've found real solution to limit perl script by CPU load. This will work this way:
# this script will use 40% CPU instead of 100% use CPU 40; 1 while 1;
Relization based on my old ideas: Simultaneous alarms < 1 sec and resource control: CPU. These ideas was united and greatly improved, simplifyed and optimized.

I will test it, create package and upload to CPAN. But I don't know best suited name for this package. Really, I think it's Right Thing to realize it in standart pragma 'less'. This pragma now unimplemented, and as far as I understand it should be realized in perl itself. I suppose to realize 'less CPU' my way in this pragma and later replace my solution to perl internal solution with same interface. The interface can look like this:

use less CPU => 40, memory => '30MB';
The problem is what there is no AUTHOR section in less.pm, so I don't know who should be contacted about this question. May be one of monks know his email? Or you think I should not touch 'less' pragma and release it in usual module with name .....?

P.S. Maybe name 'limit' is more suited for this pragma than 'less'.


In reply to use less 'CPU' by powerman

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.