Question

In: Computer Science

5. Create this hash variable: in perl language Scalar => ‘dollar sign’, Array => ‘at sign’,...

5. Create this hash variable: in perl language Scalar => ‘dollar sign’, Array => ‘at sign’, Hash => ‘percent sign’ Process it with a foreach loop that prints the key/value pairs so that the keys are printed in sorted order: Array: at sign Hash: percent sign Scalar: dollar sign.

Solutions

Expert Solution

1. Print scalar variable"

#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

my $email = "fnord\@cgi101.com";
my $url = "";

print header;
print start_html("Scalars");
print <<EndHTML;
<h2>Hello</h2>
<p>
My e-mail address is $email, and my web url is
<a href="$url">$url</a>.
</p>
EndHTML

print end_html;

Array: at sign Hash: percent sign Scalar: dollar sign

#!/usr/bin/perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

# declare the colors hash:
my %colors = (  red => "#ff0000", green=> "#00ff00",
    blue => "#0000ff",       black => "#000000",
    white => "#ffffff" );

# print the html headers
print header;
print start_html("Colors");

foreach my $color (keys %colors) {
    print "<font color=\"$colors{$color}\">$color</font>\n";   
}
print end_html;

Related Solutions

Please Solve with c language Create 5-by-5 integer array. Initialize the elements of the array starting...
Please Solve with c language Create 5-by-5 integer array. Initialize the elements of the array starting from 1. Your element [0][0] should be equal to 1; element[4][4] should be equal 25. Print the array. The output should have 5 rows and 5 columns. Specify the width for each output to demonstrate the table in a formatted view. Change the value of the elements: 2nd row 4th column to 24, 1st row 3rd column to 13. Print the array again. Find...
Indexing Arrays & Scalar Operations Create a new array called “myShortArray” that contains the 1st, 3rd,...
Indexing Arrays & Scalar Operations Create a new array called “myShortArray” that contains the 1st, 3rd, and 5th elements of the array “myArray” as defined below using the indexing method.      myArray = [1, 2, 3, 4, 5, 6];
In C Programing Create a stack using an array. Define the index variable of the array...
In C Programing Create a stack using an array. Define the index variable of the array name to be stacktop. Initially set stacktop to -1. Next create two functions push and pop. Both take as input 3 items: a pointer to the stack in memory, stacktop, and maxstack. Make sure to inc stacktop by one and also remember that stacktop[0] is the bottom of the stack and by stack rule cannot be accessed until all the other items are popped....
c++ language Create a file program that reads an int type Array size 10; the array...
c++ language Create a file program that reads an int type Array size 10; the array has already 10 numbers, but your job is to resize the array, copy old elements of array to the new one and make it user input and add an additional 5 slots in the array, and lastly do binary search based on user input. close the file.
In Perl: Create a dictionary of at least 5 key/value pairs. Add a new key/value pair...
In Perl: Create a dictionary of at least 5 key/value pairs. Add a new key/value pair to the dictionary. Change one of the values through reassignment. Access at least 3 values using the keys. Access at least 3 keys using the values. Delete an element. Test for key inclusion for 3 elements. Loop through the dictionary, printing out the key and value on the same line separated by a space. Key1, value1 Key2, value2 …,     … (Please if you...
Using C++ language, create a program that uses a struct with array variables that will loop...
Using C++ language, create a program that uses a struct with array variables that will loop at least 3 times and get the below information: First Name Last Name Job Title Employee Number Hours Worked Hourly Wage Number of Deductions Claimed Then, determine if the person is entitled to overtime and gross pay. Afterwards, determine the tax and net pay. Output everything to the screen. Use functions wherever possible. Bonus Points: Use an input file to read in an unknown...
C Language NO ARRAY UTILIZATION OR SORTING Create a .txt file with 20 integers in the...
C Language NO ARRAY UTILIZATION OR SORTING Create a .txt file with 20 integers in the range of 0 to 100. There may be repeats. The numbers must not be ordered/sorted. The task is to find and print the two smallest numbers. You must accomplish this task without sorting the file and without using arrays for any purpose. It is possible that the smallest numbers are repeated – you should print the number of occurrences of the two smallest numbers....
using c language: create an array of the values of a sine wave. Include the math.h...
using c language: create an array of the values of a sine wave. Include the math.h header to use the sin floating point function. The function sin takes an argument of radians (not degrees). Make your array721 elements and initialize each element with 10 * sin(2*3.1416* (i/360.0) where i is the array index from 0 - 720. When done properly, the array should contain approximately 2 complete sine wave cycles. Similarly, create an array of 721 elements only this time...
in C programming language char character [100] = "hello"; a string array variable It is given....
in C programming language char character [100] = "hello"; a string array variable It is given. By writing a function called TranslateString, By accessing the pointer address of this given string, returning the string's address (pointer address) by reversing the string Write the function and use it on the main function. Function void will not be written as. Return value pointer address it will be. Sweat operation on the same variable (character) It will be made. Declaration of the function...
swift language declare a Swift array variable that can hold instances of any class type
swift language declare a Swift array variable that can hold instances of any class type
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT