Tuesday, November 30, 2010

Reverse the characters in each word in a string?

Perl Script:


#!/usr/bin/perl5.8.8

$x = "the cat in the hat";

$x =~ s/(\w+)/reverse $1/ge
  
OUTPUT:
 
$x contains "eht tac ni eht tah"
 

No comments:

Post a Comment