Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I'll take a flyer and suggest a couple of possibilities depending on the behaviour you want::

1. do {} while () -- this would allow the code to execute once before 'hanging' on the while. I can't really envision how this would apply to your situation, but hey, you never know.

2. Threads -- I've got admit that I've only used threading in Java, but there are at least three threading modules on CPAN.

What you'd want to do is have one thread waiting for keyboard input -- I'm not sure what the exact syntax would be, but you'd create the thread with a low priority/nice-ness so that other processes keep running (maybe even a sleep()), and spin off your other process as a seperate thread so that it can run without waiting for keyboard input (assuming that this is the behaviour you want).

The tricky part is establishing a safe way for the two threads to talk to each other -- in Java you have Thread-safe objects/methods that you can essentially use as a lock on your data ('don't read this until I've finished writing to memory/disk...').

I suspect that in Perl this will be a little tougher, but I'm sure that someone can either a) offer actual code, or b) point you to a module, to solve your problem.

Sorry I can't offer actual code, but this is outside the scope of my normal Perl coding...


In reply to RE: When is a while not a while? by jreades
in thread When is a while not a while? by Miker

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 perusing the Monastery: (5)
As of 2024-04-19 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found