Hello Shaji, some comments about your code.
On Wed, 26 Jun 2013 17:52:13 +0800 (SGT) *Shaji Kalidasan* <shajiin...@yahoo.com> wrote: > Franklin, > > Here is one way to do it > > [code] > #Program to reverse a string without using built-in function 1. You're missing "use strict;" and "use warnings;". 2. The comment should read: « # A program to reverse a string without using the reverse() built-in function » > my $str = "Japan is the land of rising sun."; > my @str = split '', $str; 1. You're calling an array by the same name as a scalar which can get confusing. 2. Using split here is wasteful in memory and unnecessary because you can just use http://perldoc.perl.org/functions/substr.html . > for ( my $i = $#str ; $i >= 0 ; $i-- ) { > print $str[$i]; > } 1. One problem here is that the program emits the output directly to STDOUT, and so it cannot be reused as a new string. 2. Another problem is that it's an entire program - not a subroutine. Regards, Shlomi Fish > [/code] > > [output] > .nus gnisir fo dnal eht si napaJ > > [/output] > > best, > Shaji > ------------------------------------------------------------------------------- > Your talent is God's gift to you. What you do with it is your gift back to > God. > ------------------------------------------------------------------------------- -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ My Public Domain Photos - http://www.flickr.com/photos/shlomif/ God helps them that help God help them. — http://shlomif.livejournal.com/66017.html Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/