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
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
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
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 "&&"
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
&stuff();
}
else {
die "Stuff not allowed";
}