0 Replies - 1503 Views - Last Post: 26 July 2007 - 11:09 AM

#1 girasquid   User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Reversing a String

Posted 26 July 2007 - 11:09 AM

Description: This snippet will reverse a string input by the user. It is a smaller improvement on the snippet "Reverse a given string" submitted by no2pencil. The script uses the reverse command in a scalar context to affect the inputted string.
#!/usr/bin/perl -w
use strict;
print "Enter word to reverse: ";
chomp(my $word = );
my $reversedWord = scalar reverse $word;
print "Original Word: $wordn";
print "Reversed Word: $reversedWordn";

Is This A Good Question/Topic? 0
  • +

Page 1 of 1