Try this:
unless( $options{a} && $options{b} ) { do_stuff }
if both of those 2 keys have a value in the hash, the && will return true,
and the do_stuff won't get exuted
you can also use
if( !$foo && !$bar ) or some construct like that, but i find that less
legible...
also, if you want to have
;
> }
>
> - Original Message -
> From: "Mooney Christophe-CMOONEY1" <[EMAIL PROTECTED]>
> To: "Perl Beginners" <[EMAIL PROTECTED]>
> Sent: Tuesday, July 17, 2001 12:59 PM
> Subject: RE: if something equals nothing
>
>
> > Exactly
;[EMAIL PROTECTED]>; "Perl Beginners"
<[EMAIL PROTECTED]>
Sent: Tuesday, July 17, 2001 1:26 PM
Subject: Re: if something equals nothing
> On Tue, 17 Jul 2001, Tyler Longren wrote:
>
> > That doesn't seem to work. I want if a variable doesn't equal anythin
Mooney Christophe-CMOONEY1" <[EMAIL PROTECTED]>
> To: "Perl Beginners" <[EMAIL PROTECTED]>
> Sent: Tuesday, July 17, 2001 12:59 PM
> Subject: RE: if something equals nothing
>
>
> > Exactly like that, except using 'eq' instead of '==
On Tue, 17 Jul 2001, Tyler Longren wrote:
> That doesn't seem to work. I want if a variable doesn't equal anything,
> then do something. Here's a piece:
> if ($options{a} eq "" && $options{a} eq "") {
You are comparing the same thing here twice???
How about
if ( !defined($options{a}) && !def
g behind them, the usage should be printed then
too.
Thanks everyone,
Tyler
- Original Message -
From: "daniels tashi robert" <[EMAIL PROTECTED]>
To: "Mooney Christophe-CMOONEY1" <[EMAIL PROTECTED]>
Cc: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Tuesda
To: Mooney Christophe-CMOONEY1; Perl Beginners
Subject: Re: if something equals nothing
That doesn't seem to work. I want if a variable doesn't equal anything,
then do something. Here's a piece:
if ($options{a} eq "" && $options{a} eq "") {
inal Message-
> From: Tyler Longren [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 17, 2001 12:56 PM
> To: Perl Beginners
> Subject: if something equals nothing
>
>
> How do I do:
> if ($something == "") {
> # do something
> }
>
> in perl?
>
&
On Tue, 17 Jul 2001, Tyler Longren wrote:
> How do I do:
> if ($something == "") {
> # do something
> }
>
> in perl?
You can do it that but use ne instead == (that's for numeric values only),
but since an empty string returns false in a boolean context, you can say:
if(!$something) {
#..
ristophe-CMOONEY1" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Tuesday, July 17, 2001 12:59 PM
Subject: RE: if something equals nothing
> Exactly like that, except using 'eq' instead of '=='.
> A slightly easier way, though,
AIL PROTECTED]]
Sent: Tuesday, July 17, 2001 12:56 PM
To: Perl Beginners
Subject: if something equals nothing
How do I do:
if ($something == "") {
# do something
}
in perl?
Thanks,
Tyler
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTE
How do I do:
if ($something == "") {
# do something
}
in perl?
Thanks,
Tyler
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
12 matches
Mail list logo