Question

In: Computer Science

SHOW SCREEN SHOTS OF THE INPUT AND OUTPUT AS WELL AS THE RESULTS PROGRAMMING IN PERL...

SHOW SCREEN SHOTS OF THE INPUT AND OUTPUT AS WELL AS THE RESULTS

PROGRAMMING IN PERL

Task 2: Variables

2.1 Scalar Variables

A scalar is a single unit of data. That data might be an integer number, floating point, a character, a string, a paragraph, or an entire web page. Simply saying it could be anything, but only a single thing.

#!/usr/bin/perl

$age = 35; # An integer assignment

$name = "Gary Mann"; # A string

$salary = 5445.50; # A floating point

print "Age = $age\n";

print "Name = $name\n";

print "Salary = $salary\n";

Output__________________

2.2 Array Variables

An array is a variable that stores an ordered list of scalar values. Array variables are preceded by an "at" (@) sign. To refer to a single element of an array, you will use the dollar sign ($) with the variable name followed by the index of the element in square brackets.

#!/usr/bin/perl

@ages = (25, 30, 40);

@names = ("John Paul", "Lisa", "Kumar");

print "\$ages[0] = $ages[0]\n";

print "\$ages[1] = $ages[1]\n";

print "\$ages[2] = $ages[2]\n";

print "\$names[0] = $names[0]\n";

print "\$names[1] = $names[1]\n";

print "\$names[2] = $names[2]\n";

Output______________________

2.3 Hash Variables

A hash is a set of key/value pairs. Hash variables are preceded by a percent (%) sign. To refer to a single element of a hash, you will use the hash variable name followed by the "key" associated with the value in curly brackets.

#!/usr/bin/perl

%data = ('John Paul', 45, 'Lisa', 30, 'Kumar', 40);

print "\$data{'John Paul'} = $data{'John Paul'}\n";

print "\$data{'Lisa'} = $data{'Lisa'}\n";

print "\$data{'Kumar'} = $data{'Kumar'}\n";

Solutions

Expert Solution

Screen shots of the above codes

2.1

2.2

2.3


Related Solutions

Solve problems using Minitab. Show evidence that they used the program by putting screen shots of...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of the results. Will give good rating. Exercises: 1. Among the 120 applicants for a job, only 80 are qualified. If 5 of these applicants are selected at random for an interview, answer the following: to. Identify the random process b. Define a variable c. Associate the random variable with a distribution and its parameters Solve the following questions using Minitab: d. Find the probability...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of...
Solve problems using Minitab. Show evidence that they used the program by putting screen shots of the results. Will give good rating 2. On a certain cruise, there are, on average, 3 traffic accidents each month. Answer the following: to. Identify the random process b. Define a variable c. Associate the random variable with a distribution and its parameters Solve the following questions using Minitab: d. Find the probability that in a period of 2 months exactly 4 accidents will...
Perl is a programming language that can be used on Linux. Write a Perl shell script...
Perl is a programming language that can be used on Linux. Write a Perl shell script named phone.pl that prompts the user to enter first or last or any portion of person’s name, so that can be found the appropriate entry in the phone directory file called “phones”. If the user tries to enter name as the argument on the command line, he/she will get a warning message “You need to provide name when prompted by this script!” If the...
Marielab1 input your age and display what your age would be next year. submit screen shots...
Marielab1 input your age and display what your age would be next year. submit screen shots from Marie. im 24 and going to be 25 next year.
Perl Programming Please write a simple to understand Perl script that computes compound interest, based on...
Perl Programming Please write a simple to understand Perl script that computes compound interest, based on input from user for P, n, r and t.
C Programming: Write a program that accepts 2 arguments, an input file and an output file....
C Programming: Write a program that accepts 2 arguments, an input file and an output file. The program is to store in the output file the contents of the input file in reverse. If the input file looks like this: Hello World.\n This is Line 2\n This is the end.\n then the output file should look like this: \n .dne eht si sihT\n 2 eniL si sihT\n .dlroW olleH The main program should look like this: int main(int argc, char...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a...
Assisted Instruction: Has to be in PERL SCRIPTING LANGUAGE with NO SUBROUTINES Programming Exercise: Write a program in PERL with NO SUBROUTINES to allow the user to pick a type of arithmetic problem to study. An option of 1 means addition problems only, 2 means subtraction problems only, 3 means multiplication problems only, 4 means division problems only and 5 means random mixture of all these types. (Computer- Assisted Instruction) The use of computers in education is referred to as...
Run the commands used for following tasks and paste the screen shots here: a) Search/find a...
Run the commands used for following tasks and paste the screen shots here: a) Search/find a specified word in a file and display all the lines containing that word. b) List all the files and directories in the current directory (including the hidden files). c) Change to the root directory / and show a complete long listing of it. d) Append the output of file1 to file2. [1 Mark] e) Count how many lines, words and characters in file1. f)...
Draw a customer-input screen for a utility company.
Draw a customer-input screen for a utility company.
JAVA PROGRAMMING Objectives JAVA Practice incremental development. Practice getting input from and printing output for the...
JAVA PROGRAMMING Objectives JAVA Practice incremental development. Practice getting input from and printing output for the user. Write a program with conditional statements. Write a program with loops. Specifications Think of three countries you’d like to travel to and look up the conversion rate between dollars and the money used in those countries. (See http://www.ratesfx.com/ rates/rate-converter.html for conversion rates.) Write a program that will convert money from dollars into each of those three types of currency, or from one of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT