Question

Write a Perl program that prompts a use to input a line of text. If the...

Write a Perl program that prompts a use to input a line of text. If the line of text has a word that is capitalized but not ALL capitalized, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND”. For example, if the user enters “Fred,” the program outputs “FOUND.” But if the user enters “fred” or “FRED,” the program outputs “NOT FOUND.”

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

CODE


use strict;
use warnings;

sub main
{
my $input = <STDIN>; #taking input
  
# ^ and $ regex anchors to match the beginning and the end of the string respectively
# + quantifier that means 1 or more of the preceding letters
# space for any spaces in the line
#A-Z for all the capital letters
if($input =~ /^[ A-Z]+$/){ #all capitalized letters like:"FRED"
print "NOT FOUND ";
}
elsif ($input =~ /[A-Z]/) { #capitalized but not all capitalized like:"Fred"
print "FOUND ";
}
else{ #all non capitalized letters like:"fred"
print "NOT FOUND ";
}
}

main();

INPUT OUTPUT
This is for capitalized but not all capitalized
FOUND
this is for all non capitalized letters
NOT FOUND
THIS IS FOR ALL CAPITALIZED
NOT FOUND

INPUT :


Add a comment
Know the answer?
Add Answer to:
Write a Perl program that prompts a use to input a line of text. If the...
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 program that prompts a use to input a line of text. If the line of text mentions bot...

    Write a Perl program that prompts a use to input a line of text. If the line of text mentions both John and Smith, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND.” Write a Perl program that prompts a use to input a line of text. If the line of text has a word that is capitalized but not ALL capitalized, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND”. For example, if the user enters “Fred,” the program...

  • Write a Perl program that prompts a use to input a line of text. If the...

    Write a Perl program that prompts a use to input a line of text. If the line of text mentions both John and Smith, the program outputs “FOUND.” Otherwise, it outputs “NOT FOUND.” Please note: If you have already answered this question, don't answer it again. I'm seeking a second opinion.

  • Write a program that takes in a line of text as input, and outputs that line...

    Write a program that takes in a line of text as input, and outputs that line of text in reverse. You may assume that each line of text will not exceed 50 characters. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text. Ex: If the input is: Hello there Hey quit then the output is: ereht olleH уен Hint: Use the fgets function to read a string with spaces from the user...

  • please use java Write a program that prompts the user to enter line of text (including...

    please use java Write a program that prompts the user to enter line of text (including whitespace). The program then replaces the following vocals with numbers: a = 1, e = 2, i = 3, o = 4, u = 5 and outputs the result to the console. The program does not consider case, so a = 1, A = 1, e = 2, E = 2, etc. Example: Input: Hello, how are you? Output: H2ll4, h4w 1r2 y45? The...

  • Write a program that takes in a line of text as input, and outputs that line of text in reverse.

     4.24 LAB: Print string in reverse Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or 'q" for the line of text. Ex: If the input is: Hello there Hey quit the output is: ereht ollel yeH

  • Write a program in C++ that prompts the user to input the name of a text...

    Write a program in C++ that prompts the user to input the name of a text file and then outputs the number of words in the file. You can consider a

  • Write a program that takes in a line of text as input, and outputs that line of text in reverse.

    Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending when the user enters "Quit", "quit", or "q" for the line of text.Ex: If the input is:Hello there Hey quitthen the output is:ereht olleH yeHThere is a mistake in my code I can not find. my output is : ereht olleH ereht olleHyeHHow can I fix this?I saw some people use void or the function reverse but we didnt...

  • 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...

  • in c++ program Write a C + + program that prompts the user to input the...

    in c++ program Write a C + + program that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. (For example, if the elapsed time is 9630 seconds, then the output is 2:40:30.)

  • Write a PYTHON program that allows the user to navigate the lines of text in a...

    Write a PYTHON program that allows the user to navigate the lines of text in a file. The program should prompt the user for a filename and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line numbers range from 1 to the number of lines in the file. If the input is 0, the...

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