Link to home
Start Free TrialLog in
Avatar of chewlf
chewlf

asked on

Perl syntax

Hi,
Anyone can help me? I want to the AND condition in my perl script which as below:

if number > 1 and allow_yn = 'Y'
then
 ......

How should I write in perl, what is the syntax?

thanks,
Chewlf
Avatar of DVB
DVB

if (($number = 1) and (allow_yn eq "Y")) {
&stuff();
}
else {
die "Stuff not allowed";
}
Avatar of chewlf

ASKER

Hi DVB,
It seems like doesn't work. I want to meet both conditions in order to run the next statement. Can I use && here?

Thanks,
Chewlf
I suggest, you missed $ before "allow_yn"
Another error is using "=" instead of "==".

Final code is

if (($number == 1) and ($allow_yn eq "Y")) {
&stuff();
}
else {
die "Stuff not allowed";
}

you can use "and" as well as "&&"
Sorry, $number == 1 should read as $number > 1, of course
ASKER CERTIFIED SOLUTION
Avatar of BigJoe1008
BigJoe1008

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial