Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: User Feedback for Subroutines with Long Execution Time

by petesmiley (Friar)
on May 29, 2003 at 15:41 UTC ( [id://261574]=note: print w/replies, xml ) Need Help??


in reply to User Feedback for Subroutines with Long Execution Time

There are some good answers here, but they strike me as a little complicated. Why not just pass a reference to a sub that handles the info. Then all you have to do in your subroutine is call the reference on each iteration.

This is good if you're not looking for something pretty, and takes about 3 extra minutes to code.

smiles

  • Comment on Re: User Feedback for Subroutines with Long Execution Time

Replies are listed 'Best First'.
Re: Re: User Feedback for Subroutines with Long Execution Time
by arden (Curate) on May 29, 2003 at 16:41 UTC
    Re: User Feedback for Subroutines with Long Execution Time by petesmiley
    There are some good answers here, but they strike me as a little complicated. Why not just pass a reference to a sub that handles the info. Then all you have to do in your subroutine is call the reference on each iteration.
    This is good if you're not looking for something pretty, and takes about 3 extra minutes to code.

    smiles


    My thoughts exactly. I did something like this with a Perl/Tk script which compressed VERY large files. I re-wrote Zip.pm to include a referenced variable in which I put the percentage done. Then I just updated the TopLevel widget regularly.
    -Arden.

Re: Re: User Feedback for Subroutines with Long Execution Time
by Notromda (Pilgrim) on May 29, 2003 at 22:27 UTC
    For those not familiar with graphical interfaces, this is often called a "callback". In any case, one must assume that your long running process has a way of knowing how far along it is, and you'll have to have various points in the process explicitly call the callback with the current status report.
    sub statusPrint { # code to update status print shift; } sub longprocess { my &status = shift; #do stuff &status("10%"); #more stuff &status("20%"); } call it with: longprocess (\&statusPrint);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://261574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-24 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found