![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: array, assigning multi-word sentences with quotes | gctaylor | Shell Programming and Scripting | 4 | 09-05-2008 03:11 PM |
| How to get exact match sentences? | vanitham | Shell Programming and Scripting | 19 | 08-23-2008 12:43 AM |
| How to identify sentences from a text? | vanitham | Shell Programming and Scripting | 2 | 07-18-2008 12:42 AM |
| Anyways to find sentences with data format and extract it??? | cyberray | Shell Programming and Scripting | 4 | 10-30-2007 11:22 PM |
| spliting up sentences | stevox | UNIX for Dummies Questions & Answers | 2 | 04-17-2001 04:36 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Comparing 2 sentences
Hi, I need some help with Perl.
I have to make a palindrome script in Perl, where it can analyze a word or sentence that is enclosed in quotations. I need it able to tell if any of the words in the sentence are palindromes. I took 1 sentence and reversed it and assigned both to 2 separate variables. I was thinking that I can compare the 2 string variables to check if they have any words that match. I understand I need to use a regular expression variables but I'm not sure which one to use. I have tried so many types and still can't get the right answer. So far I got: #!/usr/bin/perl $pali = shift; $rpali = reverse $pali; if ($pali =~ /$rpali/i) {print "Yes!\n";} else {print "No!\n";} and yes this is homework but I'm not asking anyone to post the entire script. I know what to do but I just don't know what regular expression option to put. If that's still not allowed then I'm sorry. Thanks Last edited by bcblade; 10-03-2008 at 09:15 PM.. |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|