The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-03-2008
bcblade bcblade is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0