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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
help with ||



Mar 2, 2001, 4:40 PM

Post #1 of 2 (434 views)
help with || Can't Post

I've sorted the hash and now

if (($in{'Service'} =~ /$value/) || ($in{'Signup'} =~ /$value/)) {

or is it just

if ($in{'Service'} =~ /$value/ || $in{'Signup'} =~ /$value/) {

I seen a thread that said if you don't use perintases the || will give an error and I don't think I can use perintases when matching a value.

User / Moderator

Mar 2, 2001, 6:37 PM

Post #2 of 2 (430 views)
Re: help with || [In reply to] Can't Post

When in doubt, put parentheses around just about anything.

But in this case it is safe to leave them out because =~ is stronger than || so it will behave like you want.

The warning I gave about || was in an open statement where because the || is stronger than an 'or' there will be a change to the statement if the parentheses is missing.

These three statements will all do the same thing...

open (DATA, 'filename') || die;
open (DATA, 'filename') or die;
open DATA, 'filename' or die;

But these two statements are different from the first. Without the parentheses around the open statement, the || works on the two things surrounding it. So if you use the first one you are really getting something that behaves like the second one...

open DATA, 'filename' || die;
open DATA, ('filename' || die);

Sun Sep 9, 2001 - 1:46:40 GMT, a very special second in the epoch. How will you celebrate?


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

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