Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to Perl

 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been looking around about how to find string equality and from what I've seen I just need to use eq but if AT is entered into the following code it's saying its not equal and i'm not sure why.

 
fred rosenberger
lowercase baba
Bartender
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, to be fair, your strings are not equal.

Change line 11 to this:

note the two colons. This shows you that your string isn't what you think it is. it contains EXACTLY what you typed on the command line. and I'm pretty sure you hit THREE keys to get your "AT" (not counting shift or caps lock).

Then I suggest you look up the chomp method of perl.

 
Dustin Schreader
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help. I figured the string wasn't being parsed correctly if I'm saying that right, so I did eventually fall upon the chomp method!
 
fred rosenberger
lowercase baba
Bartender
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say the string is being parsed properly, but it's taking everything you type at the command line, not just what you want.

I had someone at work have this exact same problem last week, except he was reading lines from a file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic