Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This is based on what you did, except it prints out a status bar for "time remaining." Well, actually not a status bar. Just something along the lines of
On 22000000. Minutes required: 0.718182 On 21000000. Minutes required: 0.683761 On 20000000. Minutes required: 0.645359 On 19000000. Minutes required: 0.611250 ........
I think I liked yours the best because it was the closest in spirit to my, even slower, initial attempt. Cheers :)
use strict; use warnings; my $start = 98765432; my $start_time = time; my $div = 1000000; my $max_tries = ( ( $start - ( $start % $div) ) / $div ); my $tries; LOOP: for (my $i = $start; $i > 0; $i--) { if ( $i % $div == 0 ) { $tries++; my $tries_remaining = $max_tries - $tries; #print "tries re +maining: $tries_remaining\n"; my $seconds_per_tries = ( time() - $start_time ) / $tries; my $estimated_minutes_to_completion = $seconds_per_tries * $tr +ies_remaining / 60; $estimated_minutes_to_completion = sprintf ( "%2f", $estimated +_minutes_to_completion ); print "On $i. Minutes required: $estimated_minutes_to_completi +on\n"; } next if $i =~ /0/ or $i =~ /(\d)\d*\1/; $i % $_ and next LOOP for split '', $i; print "$i\n"; exit; }



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2024-04-26 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found