Question

this is for script for terminal or putty question 1------ 1. Write a PERL script/program based...

this is for script for terminal or putty question

1------ 1. Write a PERL script/program based on the following requirements. The program should to prompt the user for how many courses the plan to take next semester and ask the user to enter each of those courses before displaying all the information entered back on the screen.

question 2------ 2. Write a PERL script that defines/declares an array or a list of elements. The array should hold three-letter abbreviations for the first six months of the year and display the array/list. question

3------ 3. Write a PERL subroutine or function named Greetings that displays a simple hello message. Demonstrate that the function works by invoking it to show its output. question

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer. Thanks

Question 1:

Code:

#Question 1

#take user input

print "How many courses the plan to take next semester: ";

my $number = <STDIN>;

#declare an array

my @courses;

#ask user to provide the name of the course

for ( my $i = 0; $i < $number; $i++ )

{

   print "Enter the name of the courses " , $i + 1, ": ";

   $courses[$i] = <STDIN>;

}

#display the result

print "Courses taken in next semester are :\n";

for ( my $i = 0; $i < $number; $i++ )

{

   print "$courses[$i]";

  

}

======Screen shot of the code and Output======

Question 2:

Code:

#quesion 2

#declare the list /array to hold three-letter abbreviations for the first six months of the year

@months = qw/Jan Feb Mar Apr May Jun/;

#display the list

print "@months\n"

======Screen shot of the code and Output======

Question 3:

Code:

#question 3

# subroutine named Greetings that displays a simple hello message

sub Greetings {

   print "hello";

}

# main method to call subroutine

Greetings();

======Screen shot of the code and Output======

Add a comment
Know the answer?
Add Answer to:
this is for script for terminal or putty question 1------ 1. Write a PERL script/program based...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and...

    Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and age, and then calculate and display their age in days. 2. Initialize a 20-element array of numbers and print each element. 3. Get a system host name. 4. Get a web page and save it to a file. 5. List background services (daemons) on your system.

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • On question 1-3 can you please answer each script separately. Please Use Perl Scripting 1. write...

    On question 1-3 can you please answer each script separately. Please Use Perl Scripting 1. write a program that computes the circumference of a circle with a radius of 12.5. Circumference is 2π times the radius (approximately 2 times 3.141592654). The answer you get should be about 78.5. 2. Modify the program from the previous exercise to prompt for and accept a radius from the person running the program So, if the user enters 12.5 for the radius, she should...

  • Structures in C++ :- 2. Write a program that declares a structure to store the distance...

    Structures in C++ :- 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then display the record of the winner. 3. Write a program that declares a structure to store income, tax rate and tax of a person. The program defines an array of structure to store the records of five person. It inputs income...

  • Write a test program that prompt the user to enter seven numbers, stores them in an...

    Write a test program that prompt the user to enter seven numbers, stores them in an array list and do the following: 1. Displays its elements (numbers) in increasing order by invoking a method with the following header that sorts the array: public static void sort(ArrayList<Integer>list) 2. Write a method that returns and displays the sum of all numbers (elements) of the ArrayList. Using the following header: public static double sum(ArrayList<Integer>list) 3. Write a method that removes the duplicate numbers...

  • Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a funct...

    Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...

  • I matlab, write a script that obtains user input, and displays the answer to a question...

    I matlab, write a script that obtains user input, and displays the answer to a question Write a program that uses the input function to ask a user for a depth of snow, and area of a rooftop. Let's assume that the density of snow is 100 kg/m3 (feel free to play around with this as another user input). Output to the screen a message telling the user the total weight of the snow (in kg) on their roof.

  • Using MATLAB program to solve the following question please: Write a script called echostring that will...

    Using MATLAB program to solve the following question please: Write a script called echostring that will prompt the user for a string, and will echo print the string in quotes (with an extra little surprise at the end): >> echostring Enter your string: I like nap Your string was: ‘I like nap – in MATLAB class’

  • Write a menu based program implementing the following functions: (0) Write a function called displayMenu that...

    Write a menu based program implementing the following functions: (0) Write a function called displayMenu that does not take any parameters, but returns an integer representing your user's menu choice. Your program's main function should only comprise of the following: a do/while loop with the displayMenu function call inside the loop body switch/case, or if/else if/ ... for handling the calls of the functions based on the menu choice selected in displayMenu. the do/while loop should always continue as long...

  • I need help with the following question Write a script based on the program in Exercise...

    I need help with the following question Write a script based on the program in Exercise 11.13 that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text. Uppercase and lowercase letters should be counted together. Store the totals for each letter in an array, and print the values in tabular format in an HTML5 textarea after the totals have been determined. I need...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT