i tried this bt cant work
yes, it cannot work, too much stuff in blender order (random)
you're trying too many things at once in a blender
package statements do not go into if blocks
putting code in between subroutine definitions is confusing for everyone
using variables before they are defined doesn't work , Coping with Scoping
strict+warnings complains about using vars before they are defined
make more subs, make your program readable
make skimmable code :)
So you write
#!"C:\xampp\perl\bin\perl.exe" -- #!/usr/bin/perl -- ## funstuff.cgi ## 2015-04-12-03:02:07 ## ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while for " +-otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use CGI::Carp qw/ fatalsToBrowser /; use CGI; ... Main( @ARGV ); exit( 0 ); sub Main { my( $headers, $body ) = FunStuff(); print $headers, $body; } ## end sub Main sub FunStuff { my $json = JsonRes->new( RequestSomeJson() ); my $headers = CGI->new->header; my $body = $json->valuesIs; return $headers, $body; } ## end sub FunStuff sub RequestSomeJson { my $ua = ... ; return JSON::XS->new->decode( $responseObj->content ); } ## end sub RequestSomeJson { package JsonRes; sub valuesIs { my( $self ) = @_; return join '', "Names Is: $name\n", "Email Is: $email\n", "Country Is: $country\n"; } ## end sub valuesIs sub new { my $class = shift; my $self = { name => shift, email => shift, country => shift, }; bless $self, $class; return $self; } ## end sub new sub getname { my( $self ) = @_; return $self->{name}; } ## end sub getname sub getemail { my( $self ) = @_; return $self->{email}; } ## end sub getemail sub getcountry { my( $self ) = @_; return $self->{country}; } ## end sub getcountry }
Problem with JsonRes? You delete/remove all the CGI/LWP stuff from the program and only deal with JsonRes
Problem with LWP? You delete/remove all the CGI/JsonRes stuff and deal only with LWP
Problem with CGI? You delete/remove all the LWP/JsonRes stuff and deal only with LWP
You have to fix one thing at a time before you try to fix the whole thing
In reply to Re: json response ( unblender )
by Anonymous Monk
in thread json response
by bigup401
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |