Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

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

Is the code you pasted a simplified sample of the original? If not, I do not understand why you have the whole $stopvalue business in the first place. Your code progresses linearly, and the if ($stopvalue == 1) condition is pointless. At that point, $stopvalue is always set to 1.

Putting that point aside, unless you already know what fork and exec do, it would probably be best to avoid them. They are the low level primitives, and the other available methods are usually simpler and more convenient. Doing the fork/exec yourself should be reserved for times when you really need it.

In your case, I would lean toward a piping open, as it will provide enough control but also enough simplicity. As an added bonus, you'd be able to read the program's output, if necessary. Here's an example:

my $pid = open my $lsfh, "-|", "sleep", 10 or die "Cannot exec sleep: $!\n"; print "'sleep' is running in the background.\n"; print "The background process has a PID of $pid.\n"; waitpid $pid, 0; print "All done.\n";

In reply to Re^3: System Function...script does not move until process ends. by Mugatu
in thread System Function...script does not move until process ends. by curtisb

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 having an uproarious good time at the Monastery: (5)
As of 2024-04-24 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found