Perl
Write a program with a subroutine that keeps prompting for a filename until a valid file is entered by the user (print out "file found, thanks") or until five attempts have failed (print out "you did not enter a valid file name"). The sub in this case does not return any value.
#### Perl Subroutine For getting a filename and checking whether it is a valid filename ####
sub FileNamePrompt{
$attemptsRemaining = 5; ### number of attempts
$flag = 0; ###### flag which tells whether a valid filename is
entered
$fileName = "validFileName.txt"; #### a vlid filename which will
compared with entered filename
while($attemptsRemaining > 0)
{
$attemptsRemaining = $attemptsRemaining - 1;
$input = <STDIN>; ## taking filename from input
chomp $input; ### clearing extra spaces
if($input eq $fileName) ### comparing with standard valid filename
and file is found
{
print "File Found, Thanks";
$flag =1;
last;
}
}
if($flag == 0) ### if file not found
{
print "you did not enter a valid file name";
}
}
FileNamePrompt() ### calling the subroutine


Perl Write a program with a subroutine that keeps prompting for a filename until a valid...
Using Perl Program: Write a program with a subroutine to prompt the user for any message (like "what is your name?"). The sub will collect the user's answer and return it back to the call (in the main program above the subroutine). The sub does not accept any arguments. Print out the returned string (name) from the sub.
In Python, write a function numLetters() that keeps prompting the user for words until they hit return (using while loops). The function should then return the percent of 3-letter words that were entered. So, if a user entered ten words and 4 of the words had 3 letters, then the percent of 3-letter words is 40
Write a perl program Use a while loop to get user input until the user enters "quit" Use a regex to replace any occurrence of the word "python" with the word "perl" and print out the updated version Provide the perl program (.pl file) as well as a screenshot of the output (show at least one example with python being replaced)
Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...
write the c++ code that keeps prompting (10 times) the user to enter an integer. the code print out the product of all the the integers.
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...
Write a java program that keeps asking the user to enter a number until the user quits and prints how many even and how many odd numbers entered by the user. The loop terminates if the user enters -1 (it indicates that there will be no more number entering by the user). In other words, as long as the user doesn’t enter -1, the loop will be executed. Please add comments to the program to understand/ explain the code.
Write a function that takes, as an argument, the name of a file, fileName . Your program should open (and read through) the file specified, and return the maximum value in the file. Name this function maxValueInFile(fileName). def openFile(): # Prompt for the file name filename =input("Enter a file name: " ) # Open the file for reading file = open(filename) # Prompt for the target value target =input("Enter a threshold value: ") # Initialize the counter counter = 0...
Exercise 3.1 (word count.py). Write a program that takes in a filename and string as input. Then print how many times that string appears inside the chosen file. If the file does not exist, continue asking for a filename until one is given that exists. Use your source code file as test input. Make sure to test files with that contain the same word multiple times. ? $ python3 word-count.py 2 Please enter a filename: wordcount.py 3 Please enter a...
Using Python, write a program that keeps asking the user for
text until they type "exit"
To Exit Or Not Write a program that keeps asking the user for text until they type "exit" Console 1 Enter number 1 3 Enter number 5 5 Enter number 7 Enter number 8 1 9 Enter number 10 9 11 Enter number 12 3 13 Enter number 14 4 15 Enter number 16 exit 17 Bye! 18