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 ...
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/