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: Intermediate:
and or

 



Zeke_D
Deleted

Jul 17, 2000, 7:24 AM

Post #1 of 2 (1118 views)
and or Can't Post

Here is an easy one for you gurus:

I am reading data from a pipe-delimited database. there are several variables, and I want to check to see if a certin variable is true:

the reading variables is easy:
foreach (@data) {
($referer, $file, $date, $time) = split ('[|]',$_);
}

checking the variables is easy:

if ($referer eq $ENV{'HTTP_REFERER'}) {
$match = "1";
}


I want something like this:

if ($referer eq $ENV{'HTTP_REFERER'}) AND ($file eq $ENV{'HTTP_REFERER'}) then do $foo

whats the symbol for AND when checking variables? what about OR?

How about if FOO=variable1 BUT NOT FOO = variable2 ?

-thanks


Kanji
User

Jul 17, 2000, 7:52 AM

Post #2 of 2 (1118 views)
Re: and or [In reply to] Can't Post

&& = AND
| | = OR (should be no space in-between the pipes, but UBB inserts one)

&& ! = AND NOT (that's an exclamation)
| | ! = OR NOT

You can also do the NOT negation within the test (ie, $this == 2 && ! $that == 3 is the same as $this == 2 && $that != 3, or using ne instead of eq in your example).

See the perlop manpage for more info (specifically the C-style and binding operator sections).

[This message has been edited by Kanji (edited 07-17-2000).]

 
 


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

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