How do I say NOT in Perl?

How do I say NOT in Perl?

am 11.07.2006 23:19:25 von HerbF

How do write NOT-variable in Perl?

In javascript, I'd write !variable. In Perl I seem to be forced to say,
e.g., if (variable !==1) {yada}.

Thanks in advance,

Herb

Re: How do I say NOT in Perl?

am 12.07.2006 00:21:01 von dha

On 2006-07-11, HerbF@X.net wrote:
> How do write NOT-variable in Perl?
>
> In javascript, I'd write !variable. In Perl I seem to be forced to say,
> e.g., if (variable !==1) {yada}.

"if (!$x)" should work fine.

What's the actual code that's not working for you?

dha

--
David H. Adler - - http://www.panix.com/~dha/
perl -e 'print "Just another P$0-r-l hacker"'

Re: How do I say NOT in Perl?

am 12.07.2006 00:24:46 von David Dorward

HerbF@X.net wrote:

> How do write NOT-variable in Perl?
>
> In javascript, I'd write !variable. In Perl I seem to be forced to say,
> e.g., if (variable !==1) {yada}.

david:~$ perl -Mstrict -Mwarnings -e'my $v = 1; if (!$v) { print "V is not a
true value\n"; } else { print "V is a true value\n"; }'
V is a true value


--
David Dorward
Home is where the ~/.bashrc is

Re: How do I say NOT in Perl?

am 12.07.2006 05:54:25 von dha

On 2006-07-11, David Dorward wrote:
> HerbF@X.net wrote:
>
>> How do write NOT-variable in Perl?
>>
>> In javascript, I'd write !variable. In Perl I seem to be forced to say,
>> e.g., if (variable !==1) {yada}.
>
> david:~$ perl -Mstrict -Mwarnings -e'my $v = 1; if (!$v) { print "V is not a
> true value\n"; } else { print "V is a true value\n"; }'
> V is a true value

My next question is, what were you expecting to happen? Since $v *does*
have a true value, that's pretty much what I would expect...

dha

--
David H. Adler - - http://www.panix.com/~dha/
New Songs/New Members/New CD/Same rotten attitude
- Raving Noah press release

Re: How do I say NOT in Perl?

am 12.07.2006 14:00:34 von Sherm Pendley

"David H. Adler" writes:

> On 2006-07-11, David Dorward wrote:
>> HerbF@X.net wrote:
>>
>>> How do write NOT-variable in Perl?
>>>
>>> In javascript, I'd write !variable. In Perl I seem to be forced to say,
>>> e.g., if (variable !==1) {yada}.
>>
>> david:~$ perl -Mstrict -Mwarnings -e'my $v = 1; if (!$v) { print "V is not a
>> true value\n"; } else { print "V is a true value\n"; }'
>> V is a true value
>
> My next question is, what were you expecting to happen? Since $v *does*
> have a true value, that's pretty much what I would expect...

I think David D. was expecting just what he got, and wrote the above to show
that the negation operator ! works just like it does in JS.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Re: How do I say NOT in Perl?

am 12.07.2006 16:49:00 von HerbF

HerbF@X.net scribed:

>How do write NOT-variable in Perl?
>
>In javascript, I'd write !variable. In Perl I seem to be forced to say,
>e.g., if (variable !==1) {yada}.
>
Thanks to all for the help. It works fine. I must have had another issue
that I wasn't aware of.

Herb

Re: How do I say NOT in Perl?

am 12.07.2006 21:10:25 von David Dorward

Sherm Pendley wrote:
> "David H. Adler" writes:
>> On 2006-07-11, David Dorward wrote:
>>> HerbF@X.net wrote:

>>>> In javascript, I'd write !variable. In Perl I seem to be forced to say,
>>>> e.g., if (variable !==1) {yada}.

>>> david:~$ perl -Mstrict -Mwarnings -e'my $v = 1; if (!$v) { print "V is
>>> not a true value\n"; } else { print "V is a true value\n"; }'
>>> V is a true value

> I think David D. was expecting just what he got, and wrote the above to
> show that the negation operator ! works just like it does in JS.

Indeed (contrary to what the OP stated)

--
David Dorward
Home is where the ~/.bashrc is

Re: How do I say NOT in Perl?

am 12.07.2006 23:39:31 von dha

On 2006-07-12, David Dorward wrote:
> Sherm Pendley wrote:
>> "David H. Adler" writes:
>>> On 2006-07-11, David Dorward wrote:
>>>> HerbF@X.net wrote:
>
>>>>> In javascript, I'd write !variable. In Perl I seem to be forced to say,
>>>>> e.g., if (variable !==1) {yada}.
>
>>>> david:~$ perl -Mstrict -Mwarnings -e'my $v = 1; if (!$v) { print "V is
>>>> not a true value\n"; } else { print "V is a true value\n"; }'
>>>> V is a true value
>
>> I think David D. was expecting just what he got, and wrote the above to
>> show that the negation operator ! works just like it does in JS.
>
> Indeed (contrary to what the OP stated)

Right. serves me right for not reading headers. :-)

dha, goes back into hiding

--
David H. Adler - - http://www.panix.com/~dha/
"If you want a real optimist, look up Ray Bradbury. Guy's nuts.
He actually likes people." - David Brin