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

Answer Posted / venkatesh

#!/usr/bin/perl
$a = "Venky";
@c;
@b = split("", $a);
foreach $char (@b){
unshift(@c, $char);
}
$value = join("", @c);
print "$value\n";

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain chop?

705


If EXPR is an arbitrary expression, what is the difference between $Foo::{EXPR} and *{"Foo::".EXPR}?

704


You want to open and read data files with perl. How would you do that?

692


What is the different between array and hash in perl programming?

693


Explain arrays in perl.

720


You want to download the contents of a url with perl. How would you do that?

667


what is the function of Return Value?

762


Which of these is a difference between Perl and C++ ?

754


Why to use perl?

722


What is the purpose of redo statement?

737


What does read () command do?

687


What are the different instances used in cgi overhead?

764


Distinguish my and local?

714


How to concatenate strings in perl?

804


package MYCALC; use Exporter; our @EXPORT = (); our @ISA = qw(Exporter); our @EXPORT_OK = qw(addition multi); our %EXPORT_TAGS = (DEFAULT => [qw(&addition)],Both => [qw(&addition & +multi)]); sub addition { return $_[0] + $_[1]; } sub multi { return $_[0] * $_[1]; } 1; Program: use strict; use warnings; my @list = qw (2 2); use Module qw(:DEFAULT); print addition(@list),"\n"; Above coding is my module MYCALC and the program which using this module, I have not exported any function using @EXPORT, but I have used the DEFAULT in %EXPORT_TAGS with the function addition, when I call this function from the main it says the error as,

2481