Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Here is the problem: Lesson 13 OBJ1: OST Class online.
Write a script called obj13-1.pl and a library called obj13-lib.pl.
1- The library should contain a function that takes in an array of numbers (of arbitrary size).
2- The function will then (calculate the average of the numbers), (the total of all of the numbers added together), and a new array of numbers which is comprised of the (other numbers divided by 2).
It will then return a new list with all of that information.
The script file, obj13-1.pl should get a list of numbers from the user (either via STDIN or a list of arguments) and call the library function.
2. Relevant commands, code, scripts, algorithms:
3. The attempts at a solution (include all code and scripts):
My attempt at this, remember I'm a newbie to unix/linux:
Obj13-1.pl
Obj13-lib.pl
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
OST OReilly School of Technology, Online course, USA, Kelly Hoover instructor. Course is Unix/Linux administration.
Tried to post this and got this msg: So I'm taking the link to my class out.
"You are only allowed to post URLs once you have at least 5 posts"
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
Actually you've broken the spec there, your imported function from the library file should return an array with all the calculations performed, ie you should be able to call it thus
You could create the array of halves as you loop through the array and calculate the average afterwards.
For bonus points, check for an empty array so as to avoid a divide by zero error and also ensure all elements of the array you send to the function are numeric.
Returning an array reference for the @halves array wins you another bonus, no effect here, but it's better practice as it makes the function extensible and the first assignment to an array swallows all subsequent return values.
Last edited by Skrynesaver; 05-17-2011 at 10:04 AM..
Reason: advised on potential approach
Hi I just started scripting in my Unix class, but can't understand it and have trouble with homework. This is my homework:
Dean needs a daily written report of the status of his Unix computer. He wants to obtain certain information about users and processes that are only accessible by executing... (1 Reply)
Hi Experts,
I'm stuck with a single liner bash script. Need your help to fix it.
Let me brief you that what is my expectations from this script.
I need the interfaces configured for a list of servers, their respective IP address and FQDN in a output file. The output should be in the same... (3 Replies)
Hi experts...
I am really new to this scripting, i really need your help.
I have this script to read and print the report, however the script does not pickup the correct hostname (eg. Svtns11d)..
The script will start reading/pick up on the second line instead of reading the first line.... (1 Reply)
Gents,
I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Hi all,
I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first.
Can you please help me determine which one to... (14 Replies)
Hi
How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Hello im currently taking up Operating Systems and we're on unix ryt now. we have to make a script and here are the requirements.. can someone please help me. I would reli appreciate it.. because i dont reli know how to make scripts yet.
Name of script : parkingcharge.sh
Create a script that... (1 Reply)
The Perl script runs fine without any error from command line. The script executes an external command and prints the output on a web page. But somehow when I call it from URL it does not work. Any help will be appreciated. Here is the script:
--test.pl
#!/usr/bin/perl
#
use warnings;
use... (23 Replies)