!!!1 is nothing?

[email protected] (hw via beginners)
Newsgroups perl.beginners
Message-ID <[email protected]>
Hi,

I'm wondering why I get nothing from a 'direct' version of:


sub get_ison($self) {
    my $stuff = $self->get_status;

    # yields "'output' => !!1" when on and "'output' => !!0" when off
    if($stuff->{output} == 1) {
	return 1;
    }

    return 0;
}

sub get_isoff($self) {
    # for unknown reasons, "return !$self->get_ison" yields nothing
    if($self->get_ison == 1) {
	return 0;
    }

    return 1;
}


$stuff in this case is the result of basically:


use LWP::UserAgent();
use JSON::Parse qw(parse_json);

    my $ua = LWP::UserAgent->new();
    my $response = $ua->get("http://example.org");
    my $stuff = parse_json( $response->decoded_content );


When I use


sub get_isoff($self) {
    return !$self->get_ison;
}


instead of the 'indirect' way above and have


say $switch->get_isoff;


in the caller, it prints a blank line instead of either 1 or 0.

Any idea why that is?  Is there some kind of wierd evaluating of '!!1'
or '!!0' going on?  Even '!!!1' should evaluate to 0 and not to
nothing.

When I do the same http request with a web browser, I get


output:	true


which is what I expected in perl as well ...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.