Write a script to reverse a string without using Perl's
built in function

Answer Posted / vipul dalwala

#!/usr/bin/perl

my $str = "hello";
$revstr = "";

while($str =~ /(.)/g)
{
$revstr = $1.$revstr;
}

print $revstr."\n";

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

460


Explain what is the scalar data and scalar variables in Perl?

565


What does a die() function do in perl?

538


How to turn on Perl warnings? Why is that important?

576


Show the use of sockets for the server and client side of a conversation?

470






Explain subroutine in perl?

484


What are perl strings?

506


What is goto statement in perl?

510


Explain chop?

534


What is an interpolation in perl?

559


Explain grooving and shortening of arrays and splicing of arrays?

498


Explain the different types of data perl can handle.

489


Write a program that explains the symbolic table clearly.

526


Give an example of using the -n and -p option.

536


What are stdin, stdout and stderr?

515