CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
String comparisons... which is better?

 



Calab
Novice


Aug 29, 2012, 10:36 PM

Post #1 of 3 (756 views)
String comparisons... which is better? Can't Post

When doing a string comparison, which is better?

if ( $mystring eq 'abc' )

...or...

if ( "$mystring" eq 'abc' )

???


Laurent_R
Enthusiast / Moderator

Aug 30, 2012, 1:45 AM

Post #2 of 3 (755 views)
Re: [Calab] String comparisons... which is better? [In reply to] Can't Post

Both versions will work, but I would use the first one, which is simpler and more natural.


BillKSmith
Veteran

Aug 30, 2012, 4:40 AM

Post #3 of 3 (746 views)
Re: [Calab] String comparisons... which is better? [In reply to] Can't Post

Read the FAQ: perldoc -q "What's wrong with always quoting"
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives