Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!evax!utacfd!letni!mic!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: palindromes Message-ID: <110907@convex.convex.com> Date: 13 Dec 90 06:38:09 GMT Sender: usenet@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 42 Somewhat in the spirit of Steve Hayman's recent program (using perl to play with words), I thought of this: % perl -ne 'chop;print "$_\n" if $_ eq reverse' /usr/dict/words or as a program to sort them as well: #!/usr/bin/perl while (<>) { $word = $_; chop; y/A-Z/a-z/; next unless $_ eq reverse; # don't put revsrse here as i did push(@words, $word); } print sort bylen @words; sub bylen { length($b) <=> length($a); } Run on /usr/dict/words, I get this (abridged): Malayalam Adinida hallah alula rotor lemel deedeed retter degged madam kelek radar reviver redder Ajaja yaray Tebet level sooloos terret ajaja civic siris rever Senones tebbet Ababa Kazak Arara refer rotator Kassak kayak ululu arara mesem repaper kakkak Alala tenet Seres minim murdrum Hannah alala anana Samas I had thought there were that were longer ones. And does anyone else think my dictionary has funny words in it? I sure don't know most of those, but maybe my liberal arts education just isn't what it was cracked up to be. :-) Well, at least now I know that Malayalam is a Dravidian language (???) spoken on the Malabar Coast in southeastern Asia. :-) --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me