develooper Front page | perl.beginners | Postings from September 2009

Re: !! notation

Thread Previous
From:
Shawn H Corey
Date:
September 9, 2009 07:41
Subject:
Re: !! notation
Message ID:
4AA7BE45.2000103@gmail.com
Dermot wrote:
> Hi,
> 
> I saw this notation today:
> 
> !! $class->method;
> 
> or as an assignment:
> 
> my $var = !! $class->method;
> 
> I can't find a definition for it in perlsyn or perlop. I don't think
> it's restricted to classes. I suspect this is boolean but I'd like to
> know.
> 
> Any pointers?
> Thanx,
> Dp.
> 

my $var = ! ( ! ( $foo ) );

It is a double negation; see `perldoc perlop` and search for /Symbolic 
Unary Operators/

It has two effects:

1. It converts an undef (and other false thingys) into an empty string.

2. It converts non-false thingys into 1.


-- 
Just my 0.00000002 million dollars worth,
   Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About