Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
OK, this seems like a problem that someone else must have run into before, so I'm looking for advice from the fantastic Monks.
I'm running a script that uses Text::Balanced to parse blocks of code with balanced braces. The script itself runs great, but since not everyone using this script will be as careful as I am (heh heh) I'm building in some error handling and diagnosis etc. One feature that I have is sort of combo looking cool/actually helpful. Basically, the pertinent piece of code looks like this:
while($next = (extract_bracketed($text, '{}', '[^{}]*' ))[0]) { $holder = $next; $next =~ s/\{([\w|-]*)(.*)\}/<$1>$2<\/$1>/osi; $text =~ s/$holder/$next/sgi; print "Sync check \#$counter\n"; print "$next\n"; $counter++; }
OK, fair enough. The code works nicely, spits out a little counter number and displays the code block currently being processed. So I found this pretty handy if/when a piece of sample input went into an infinite loop or something, I could actually see it not changing. Now what I'd like to offer other users of this code is the ability to stop/start the code while in the loop above, so that they could actually stop the output, look at the half processed block, then start it again. I figure this would be handy for folks trying to understand the way the tool works, plus handy for people trying to debug a problem with the way my code and their input interact. So how to best implement this? I've looked at the sleep() function, which could be cool. Should I just put a sleep(10) in an if(the foo key is struck) type of statement within the while loop? If this isn't practical or possible without big problems for the code, no biggy. I'm just wondering if anyone has already dealt with this problem in their own work and found a neat solution. Thanks Monks!

In reply to How can a user pause a running script? by tshabet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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: (6)
As of 2024-04-24 08:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found