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:
help with ||

 



Aquilo
journeyman

Mar 2, 2001, 4:40 PM

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

I've sorted the hash and now

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

or is it just

Code
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.



rGeoffrey
User / Moderator

Mar 2, 2001, 6:37 PM

Post #2 of 2 (382 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