Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Reply to Thread

Post a reply to the thread: Why isn't this compare function working in Perl?

Your Message

Click here to log in

What is the sum of 36 and 12

 
 

You may choose an icon for your message from this list

Additional Options

  • Will turn www.example.com into [URL]http://www.example.com[/URL].

Rate Thread

You may rate this thread from 1-star (Terrible) to 5-stars (Excellent) if you wish to do so.

Topic Review (Newest First)

  • 03-01-2013, 02:00 PM
    Jacob

    Why isn't this compare function working in Perl?

    I have this code
    http://ideone.com/QC0Ajw
    <script type="text/javascript" src="http://ideone.com/api/embed.js/link/QC0Ajw"></script>

    If the above didn't show up this is the code:
    print "Enter the word";
    $keyword = <>;
    $zippy = 'the';
    if (($zippy cmp $keyword) == 0) {
    print "yes we can\n";
    }

    The keyword I enter is:
    the

    The if statement fails and the program does not print "yes we can"

    Why isn't this working? Isn't the keyword the same as 'the'?
    @analprogrammer
    The if statement still fails, using:
    if ($zippy eq $keyword)

    I have also tried using quotes " instead of apostrophes '
    Makes no difference

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •