packetstormer has asked for the wisdom of the Perl Monks concerning the following question:
Hello
This is a simple problem and I am sure it is staring me in the face. The page below loads and reads an XML value by get. The value will always be either "true" of "false". If I print the value to screen I can see clearly that it only every equals one of those 2 values, however, my if clause isn't working? That is, even though when $get is equal to false the text doesn't print.#!/usr/bin/perl use strict; use LWP::Simple; use XML::Simple; use CGI; print "Content-type: text/html\n\n"; my $q = CGI->new; my $post = 'http://192.168.1.45/web/powerstate'; my $power = $q->param('power'); if($power eq "toggle") { get("$post"."?newstate=0"); } print "<br />"; my $get = get($post); chomp $get; # THIS PART IS FAILING if($get eq "false") { print "Box is currently on"; } print $get; print <<HTML; <form method="post" action="power.pl"> <input type="hidden" name="power" value="toggle"> <input type="submit" value="Change Power State"> </form> </body> HTML
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Posted Value "ne" not working
by Corion (Patriarch) on Sep 12, 2011 at 20:17 UTC | |
Re: Posted Value "eq" not working
by Caio (Acolyte) on Sep 12, 2011 at 21:06 UTC | |
Re: Posted Value "eq" not working
by onelesd (Pilgrim) on Sep 12, 2011 at 23:35 UTC | |
by pvaldes (Chaplain) on Sep 13, 2011 at 11:50 UTC | |
the Perl debugger is your friend...
by shriken (Priest) on Sep 13, 2011 at 14:33 UTC |
Back to
Seekers of Perl Wisdom