CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
substr() and reverse() functions


New User

Jul 2, 2015, 1:03 PM

Post #1 of 2 (2307 views)
substr() and reverse() functions Can't Post

Hi, i need som help, im new in programing,

the question I need to solve:

The scrambling should be achieved by reversing the
first and last $number characters of $string (in that order). To avoid giving any hints as to
the values used the scrambled string should appear all in lowercase. For example:
String=Babraham Number=2, Scrambed= abbrahma
String=Institute Number=3, Scrambled=snititetu
Hint: use the substr() and reverse() functions.

very happy if someone could help me Smile

Veteran / Moderator

Jul 3, 2015, 12:00 AM

Post #2 of 2 (2269 views)
Re: [dossantos17] substr() and reverse() functions [In reply to] Can't Post

hmm, this looks like a homework assignment, and this is really easy. Look at the perldoc for the two functions suggested (as well as the lc function for lower case).

To get you started, for the beginning of the string:

my $start = substr $string, 2; 
$start = lc $start;
$start = reverse $start;

Or, all in one line:

my $start = reverse lc substr $string, 2;


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives