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:
(Exclaimation point in front of variable

 



Fishhead
Novice

Aug 3, 2009, 5:16 PM

Post #1 of 3 (513 views)
(Exclaimation point in front of variable Can't Post

I am new to perl, but have worked with fortran, basic, and visual basic in the past. I am still struggling with the syntax issues. In reviewing some code that I downloaded, I found an IF statement the looks like this:

if (!$percent) {

I have two questions and I suspect the answers will be related. 1) what does the ! prior to the variable name indicate, and 2) why is there no condition within the parentheses?

Thanks


KevinR
Veteran


Aug 3, 2009, 5:28 PM

Post #2 of 3 (512 views)
Re: [Fishhead] (Exclaimation point in front of variable [In reply to] Can't Post

it reads:


Code
if (not $percent) { 
do something
}



It basically is testing if $percent is false, which is the condition. False in perl means it could have an empty value, or the value is zero.
-------------------------------------------------


(This post was edited by KevinR on Aug 3, 2009, 5:28 PM)


Fishhead
Novice

Aug 4, 2009, 7:20 AM

Post #3 of 3 (500 views)
Re: [Fishhead] (Exclaimation point in front of variable [In reply to] Can't Post

Thanks KevinR, I have another question but I will post it separately.

 
 


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

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