Question

 Write a Perl script that accepts exactly 2 integer arguments where the first argument must be less than the second argument. The script will print a comma separated list of integers starting with the first argument up through the second argument.

 The last printed value should be the second command line argument not be followed by a comma.

 The script should also be able to handle the following errorsituations:

o incorrect number of arguments

o the first argument is not less than the second argument (don’t worry about trying to handle non-integer arguments)

 The script file name must be: intlist.pl

 The script must be located in $HOME/itec400/homework

 Make sure the permissions on the your itec400 directory are 705

 Make sure the permissions on your script are 705

Sample Output • Sunny Day Scenarios >intlist.pl 3 13 3,4,5,6,7,8,9,10,11,12,13 >intlist.pl -37 -3,-2,-1,0,1,2,3,4,5,6,7 Rainy

***Please use the template below - replace X***

#!/usr/XXX/XXX # Script names: intlist.pl # Case #1: ./intlist.pl <lower integer value> <higher integer> value # Check for th

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

Code:

unless($#ARGV+1==2){
print "error: incorrect number of parameters \n";
print "usage: intlst.pl a b (where a<b)\n";
exit;
}

if($ARGV[0] >= $ARGV[1]){
print "error: incorrect number of parameters \n";
print "usage: intlst.pl a b (where a<b)\n";
exit;
}
else{
$COUNTER=$ARGV[0];
while($COUNTER<= $ARGV[1]){
print $COUNTER;
if($COUNTER < $ARGV[1]){
print ", ";
}
else{
print "\n";
}
$COUNTER = $COUNTER + 1;
}
  
}

Output:

Command Line Arguments 15 Result CPU Time: 0.00 sec(s), Memory: 5284 kilobyte(s) 1, 2, 3, 4, 5

To change permissions of a directory of a file you can use below command:

chmod 705 <directory_name/file_name>

To change script permissions to 705 you can use the command: chmod 705 intlist.pl

Add a comment
Know the answer?
Add Answer to:
 Write a Perl script that accepts exactly 2 integer arguments where the first argument must...
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 the bash script Write a script compress_large_files.sh. This script accepts one or more command line...

    write the bash script Write a script compress_large_files.sh. This script accepts one or more command line arguments. The first argument has to be an integer; let’s call it size. If this is the only command line argument, compress_large_files.sh inspects all files in the current working directory and compresses every file of size at least size. If there is more than one command line argument, all arguments except the first one must be valid directories. In this case, compress_large_files.sh inspects the...

  • Command line input In C++ it is possible to accept command line arguments. Command-line arguments are...

    Command line input In C++ it is possible to accept command line arguments. Command-line arguments are given after the name of a program in command-line operating systems like Linux and are passed in to the program from the operating system. To use command line arguments in the program, it must first understand the full declaration of the main function, which until now has accepted no arguments. In fact, main can accept two arguments: one argument is number of command line...

  • Problem: Write a program that behaves as described below.If the first command-line argument after the program...

    Problem: Write a program that behaves as described below.If the first command-line argument after the program name (argv[1]) is “--help”, print the usage information for the program. If that argument is not “--help”, you are to expectargv[1]and subsequent arguments to be real numbers(C, integer, float, or double types)in formats acceptable to the sscanf()function of the C library or strings of ASCII chars that are not readable as real numbers. You are to read the numbers, count them and calculate the...

  • In this exercise, you will create a script called if_then_else.sh that uses an IF THEN ELSE...

    In this exercise, you will create a script called if_then_else.sh that uses an IF THEN ELSE statement. The if_then_else.sh script will Use one command line argument, which will be a number between 1 and 10 Assign the value of the first argument to a local variable called NUM. HINT: Look at line 5 in the example screenshot for arguments.sh Use one IF THEN ELSE statement to compare the value of NUM If the number is less than 5, display the...

  • 1) Write a public static method named printArray, that takes two arguments. The first argument is...

    1) Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument. For example, given the following Array declaration and instantiation: int[] myArray = {1, 22, 333, 400, 5005, 9}; printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9 printArray(myArray,...

  • Part 1: Create a shell script that returns a full name associated with a userid specified...

    Part 1: Create a shell script that returns a full name associated with a userid specified in the command line argument. • Use the names found in /acct/common/CSCE215-Spring19. • Your shell script should be named “findName.sh” – Example usage: $ ./findName.sh seiei SETSUNA F SEIEI $ – Your shell script must either: Return the full name associated with the userid or Return an error message if the command line arguments are not equal to 1. or Return the message “Sorry...

  • Write a program that determines if a string (passed as a command-line argument) has all unique...

    Write a program that determines if a string (passed as a command-line argument) has all unique characters. The program must print the number of times each existing character appears, and then print whether or not they are all unique. Special requirements: You are NOT allowed to modify the input string or create any additional data structures (no arrays, lists, dictionaries, or other strings). You may have only one string (the one received as the command-line argument). You may have one...

  • (C++) Write a function that accepts an int array and the array’s size as arguments. The function...

    (C++)Write a function that accepts an int array and the array’s size as arguments.The function should create a new array that is twice the size of the argument array.The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0.The function should return a pointer to the new array.Demonstrate the function by using it in a main program that reads an integer N (that is not more...

  • Write a program in C or a script in bash, called “compare” that takes two numbers on the command line and compares them....

    Write a program in C or a script in bash, called “compare” that takes two numbers on the command line and compares them. The program should print the result of the comparison. Specifically, it should print “<x> is <comparison> <y>”, where <x> is the first number, <y> is the second number and <comparison> is one of “equal to”, “greater than” or “less than”. If the two numbers are equal, the program should have an exit status of zero. The exit...

  • The first script is validate.sh. This is a simple form validation script that will be used...

    The first script is validate.sh. This is a simple form validation script that will be used to verify the inputs given. Normally, this would be done to validate input from a website or another program before entry into a database or other record storage. In this case, we will keep it simple and only focus on the input validation step. In particular, the script should prompt the user for four values: first name, last name, zip code, and email address....

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