[Perl] Word/Text Manipulation
Gabor Szabo
gabor at tracert.com
Mon Jun 24 02:17:08 PDT 2002
On Mon, 24 Jun 2002, Georges EL OJAIMI wrote:
> Hi,
>
> I'm trying to play with word occurrences in a text file, I know it can
> be done in many ways, but is there any smart function for the
> manipulations of these words!
> 1) I want to convert all occurrences of the letters: o,j,a,i,m,i to
> uppercase!
for this you could use
$line =~ tr/ojaim/IJAIM/;
see also perldoc perlop
> 2) I want to reverse the order of the letters of a word!
for this you can use the reverse function in scalar context
e.g.
print scalar reverse $word;
will print the string in $word with its characters in reverse order
see also perldoc -f reverse
-- Gabor
More information about the Perl
mailing list