Pearly Perl
Wednesday, August 18, 2010
Perl Script to reverse a string
Program:
#!/depot/perl-5.8.3/bin/perl
my $str1="Madam i m adaM";
print "ORIGINAL_STRING: $str1 \n";
my $l=length($str1);
my $rev="";
while ($l >0) {
$l--;
$rev .= substr($str1,$l,1);
}
print "REVERSED_STRING: $rev \n";
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment