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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.