Question
Write a Perl program that will do the following: It will accept three command-line arguments: The first will be a beginning number for a range
Write a Perl program that will do the following:
It will accept three command-line arguments:
- The first will be a beginning number for a range of random numbers to be generated.
- The second will be an ending number for a range of random numbers to be generated.
- The third will be how many random numbers each process should generate.
For example, if the call to the program was mark-a11.pl 100 1000 200
The program should create four child processes. Each process should generate 200 random numbers between 100 and 1000.
After the parent process creates the child processes, it should wait so that the child processes can finish. The child processes should send the sum of its generated numbers to the parent using a pipe. The parent should compute the global mean of all the data (rounded to the nearest tenth) and send that mean back to each of the four child processes using the pipe. Each child process will display a single line (shown at bottom of report) summarizing its statistics.
The parent process should generate a report heading (to the screen). The entire output looks like this:
Range of numbers: 100 through 1000
Numbers generated by each process: 200
Global Mean (rounded to nearest tenth): 547.2
Analysis compared to the global mean:
Process PID Mean Below Above
------- ----- ----- ----- -----
0 14921 552.1 94 106
1 14922 553.7 105 94
2 14923 549.8 101 99
3 14925 549.0 103 97
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started