Question

Write a Perl script that creates a string variable with value “This is String One”. Converts...

  1. Write a Perl script that creates a string variable with value “This is String One”. Converts it into array, replaces value of element 2 from “String” to “Act” and transforms array back to string. Finally, it prints original string, array and transformed string.

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

Answer) The Perl code the above question is below:

# This is our input string
$sentence = "This is String One";
  
# converting the string sentence into array
# by using split() function
my @spl = split(' ', $sentence);


# changing the element at index 2 to "Act"
@spl[2]="Act";

# joining the array back to string
$str = join(" ", @spl );


# printing the original string i.e sentence
print "The Original String: ";
print "$sentence\n";

# printing the array i.e spl
print "The array after spliting: ";
print "@spl\n";

# printing the transformed string i.e str
print "The transformed String: ";
print "$str\n";

CODE SCREENSHOT

OUTPUT SCREENSHOT

Add a comment
Know the answer?
Add Answer to:
Write a Perl script that creates a string variable with value “This is String One”. Converts...
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
  • this is for script for terminal or putty question 1------ 1. Write a PERL script/program based...

    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 perl script to accomplish following tasks: 1. Prompt user to enter their name and...

    Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and age, and then calculate and display their age in days. 2. Initialize a 20-element array of numbers and print each element. 3. Get a system host name. 4. Get a web page and save it to a file. 5. List background services (daemons) on your system.

  • Write a C++ program that reads a string and creates a cyclical array. A cyclical array...

    Write a C++ program that reads a string and creates a cyclical array. A cyclical array is an array when the last element is pointing to the first one. Then write a loop that uses pointers and loops through the array starting from the first element and finishes after it visits the first element 5 times.

  • SHOW INPUT AND OUTPUT OF EVERYTHING .ALSO SCREEN SHOT THE RESULTS. PROGRAMMING IN PERL 2.8 Special...

    SHOW INPUT AND OUTPUT OF EVERYTHING .ALSO SCREEN SHOT THE RESULTS. PROGRAMMING IN PERL 2.8 Special Literals Three special literals __FILE__, __LINE__, and __PACKAGE__ represent the current filename, line number, and package name at that point in your program. They may be used only as separate tokens and will not be interpolated into strings. #!/usr/bin/perl print "File name ". __FILE__ . "\n"; print "Line Number " . __LINE__ ."\n"; print "Package " . __PACKAGE__ ."\n"; # theycan not be interpolated...

  • PYTHON 1- Write a function that receives a string value as a parameter, converts its first...

    PYTHON 1- Write a function that receives a string value as a parameter, converts its first character to uppercase and returns the first character. 2- Test your function by writing a main, which calls your function and prints its return value. 3- Save your program in a file called firstChar.py and use the following link to submit your file.  

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

  • 1. Write a function that converts a string into an int. Assume the int is between...

    1. Write a function that converts a string into an int. Assume the int is between 10 and 99. Do not use the atoi() or the stoi() function. 2. Write a function prototype for problem 1. 3. Write a function call for the function you defined in problem 1. 4. Write a function that converts an int between 10 and 99 into a string. 5. Write a function prototype for problem 4. 6. Write a function call for function you...

  • Write a Java program that does the following: 1. Creates a string array called firstNames that...

    Write a Java program that does the following: 1. Creates a string array called firstNames that holds these values "John", "Frank", "Nick", "Amanda", "Brittany", "Amy", "Deborah", and "Stirling". 2. Creates another string array called lastNames that holds these values "Thompson", "Smith", "Jones", "Keribarian", "Lu", "Banafsheh", "Spielberg", "Jordan", "Castle" and "Simpson". 3. Now add a method that creates an array list called randomNames which picks a random first name from the array in step 1 and a random last name in...

  • Modern language elements Write a string store class to manage string value in a member variable named        string. The variable’s value should be setable and retrievable using a property named Data....

    Modern language elements Write a string store class to manage string value in a member variable named        string. The variable’s value should be setable and retrievable using a property named Data. The string store class must also publish an event which is emitted if the data field’s value is changed to null. The event must provide the number of times the value was changed to null (including the current case) as its parameter. The event should not be emitted if...

  •  Write a Perl script that accepts exactly 2 integer arguments where the first argument must...

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

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